Ask HN: How do I build email server like AWS Ses
Hey
how can I build real private email server with incoming spam filters for domain There are so many pieces scattered around the web but no complite picture.
Thanks
how can I build real private email server with incoming spam filters for domain There are so many pieces scattered around the web but no complite picture.
Thanks
25 comments
[ 3.1 ms ] story [ 41.6 ms ] threadI think setting it up is not as difficult as to maintain and make sure emails are not bounced back, etc.
Implement SMTP.
https://github.com/haraka/Haraka
But of course there are other softwares and the choice pretty much depends on your requirements regarding scale, security and ease of setup or maintenance. The reason why things are so scattered is probably because even in basic setups, there are a number of technologies involved, like for Spam filtering, SPF and DKIM. And not many people do this kind of thing because there's Gmail. ;-)
But if you are just looking for anything to get started, there are some Docker setups which do exactly what you ask for: https://github.com/tomav/docker-mailserver
> With iRedMail, you can deploy an OPEN SOURCE, FULLY FLEDGED, FULL-FEATURED mail server in several minutes, for free.
> We did the heavy lifting of putting all the open source components together and applying best practices. Our product does all the major tasks for you. Furthermore we offer professional support to back you up in case you have some problems.
So google for postfix, dovecot, mysql, dkim, roundcube and figure out how to glue it all together. Advise: start with an unused domain, not with your everyday mail address, migration can be done when everything is tested and running.
First thing important to note, for email clients to be compatible you need to have your system support IMAP/POP3 which you cannot do in a serverless way because it requires an open Socket connection, so you need at least one cloud machine. So either 1) you make your own email client for your system (speaks to a custom backend which interacts with SES), or 2) you create a custom implementation of IMAP/POP3 which makes calls to your backend and bridges SES with the IMAP/POP3 Right now my solution is number 1, but 2 makes more sense in the long term.
I'll have something up and running to show in a couple of weeks hopefully; and I'll post it here when I get time to write it all up. If you want more info now, I can give it but it's a bit of a long writeup in itself.
SES sets up the ability to send or receive email. The receiving is handled by SES by either creating an SNS notification and/or storing the email (in MIME format) into an S3 bucket. Now let's say you've configured SES to store the email to S3 and emit an SNS notification, if you want to create a backend that will allow you to read the emails, you'll want to handle the SNS notification (via a subscribed Lambda, or a service in EC2 polling a SQS which is subscribed to the SNS) and store some of the email metadata in a database (like DynamoDB or Aurora) so that you can search the emails easier. The SNS notification tells you the email information as well as telling you the name of the file that it will create in S3, so if you store all this in the database you can load the raw email later (e.g. to get the attachments) Now let's say you have a searchable database, you'll want to make a service that allows a front-end (website or app) to read this information. So you'll want to make a backend REST API which allows users to get emails for a particular user by searching the database for emails to that user. If you're making this for users other than yourself, you'll also probably want some more user specific information in another, user-orientated, database like which stores which users have read which emails. And you'll also want to setup some user authentication/authorisation so only the right users can read the right emails.
Anyways that's how you setup recieving. To setup sending is much simpler, and I'd just follow the documentation.