I need help creating a throwaway email service similar to those temporary mail websites, but I want it running on my personal domain name. The goal is to automatically create random email addresses that can receive messages and make them accessible through some kind of programming interface.
For example, I want to generate addresses like [email protected] or [email protected] and then fetch any incoming mail programmatically. I’m looking for advice on the best approach to implement this. Has anyone worked with mail servers like Postfix or commercial services that could handle this kind of setup?
Any suggestions on tools, configurations, or alternative methods would be really helpful. I’m open to both self-hosted solutions and third-party services that support custom domains.
mailgun has a pretty decent inbound api that lets you handle custom domains without the headache of managing your own mail server. just setup mx records pointing to their servers and configure a webhook to catch incoming mail. way less hassle than postfix imo and you dont have to worry about deliverabilty issues or getting blacklisted.
I actually built something similar last year using a combination of Cloudflare Email Routing and a simple webhook handler. The setup was surprisingly straightforward compared to managing a full mail server. I configured Cloudflare to catch all emails for my domain using a wildcard rule (*@mydomain.com) and forward them to a webhook endpoint I created. The webhook processes incoming messages and stores them in a database with the recipient address as the key. This approach eliminates the complexity of running Postfix while still giving you full programmatic control. The main limitation is that these addresses are receive-only, but for most disposable email use cases that works perfectly. Cloudflare’s email routing is free for reasonable volumes and much more reliable than self-hosting. You can then build a simple API around your storage solution to query messages by email address.
Setting up Postfix with a catch-all configuration worked well for my implementation. I configured the mail server to accept any address at my domain and pipe all incoming messages to a custom Python script that parses the email content and stores it in MongoDB. The key was modifying the /etc/postfix/virtual file to route everything to a single local user, then using procmail to execute my processing script. One thing I learned the hard way is that you need proper SPF and DKIM records configured, otherwise many providers will reject or spam-filter your domain entirely. Also consider implementing some basic rate limiting in your script because you will get spam attempts once the domain starts receiving mail. The biggest advantage of this approach over third-party services is complete control over data retention and privacy. I can automatically purge old messages and there are no external dependencies. Performance has been solid handling several hundred emails daily on a basic VPS.