Free* Serverless Email Service in 20 minutes
Preamble
Hi everyone,
Sooner or later every Company, Startup or even individual will require a professional-looking email address.
Since every bit of email you send or receive has to live somewhere, it means you need a Server or a Service that will house it.
So what are our options?
Let’s review some of them.
Email Server/Service Market
Self-hosted Way
We could go with:
- old-style self-hosted Postfix/Dovecot setup
- or something cooler like mailu.io
- or docker-mailserver
Of course with all underlining headache of maintenance, compliances, compute power required to run it and so on.
Not cool in the Age of SaaS!
Plus it is 2021, so there ‘s gotta be cheap solutions out there, right?
Hosting-Based Way
There is a wide variety of Hosting Providers that will range from 7-20 USD/mo for 5 users at the moment.
Of course, usually it means you ‘ll need to buy a whole package: shared hosting, maybe virtual private server(vps) and other unnecessary bunch of stuff.
Cloud-Based Way
- protonmail will charge you 45 USD/mo for 5 users at the moment
- Gsuite Business Starter will charge you 30 USD/mo for 5 users at the moment
Domain-Providers Way
That’s kinda interesting, as i’ve never paid attention they provide such service, but for example GoDaddy actually does.
At the end, you ‘ll pay around 15 USD/mo per 5 users and gonna use Microsoft Teams to access it.
Conclusion
Sure those are not crazy numbers, however, for some brave but poor Startup or individual, this might become an unwanted spending.
Can we find a even cheaper solution or…not to pay at all?
Turns out you can.
Amazon SES
Amazon SES stands for Simple Email Service, it is obviously Cloud-Based and removes all the hustle with managing its underlining infrastructure.
Naturally, it can send emails but most importantly - receive them as well.
SES is also very kind in terms of pricing:
Except for similar “0x4447_product_s3_email” project and bits and pieces across the web, I haven’t found modern solution, so i’ve took the liberty creating it myself
Let’s see it in action!
Preparation
For starters, let’s get the repo:
% git clone https://github.com/leshcat/serverless-email-service.git
% cd serverless-email-service
According to README, we should go through next steps:
- Create accounts & install binaries
-
Remove SES from “Sandbox” for ability to send emails everywhere
Basically, you are obliged to write a short Support Ticket explaining how exactly you are going to use your SES.
Once done, soon enough Amazon guys will review your request and your SES state will switch from “Sandbox”:
to a Proud “Production” state:
-
Create an S3 bucket for Terraform remote state storage you’ve provided in variable in step above
For my trial run, I ‘ve chosen following name for my S3 bucket:
ldhq-us-east-1-ses-tfstate
-
Here is my choice:
% cp us-east-1.tfvars.example us-east-1.tfvars % cat us-east-1.tfvars
config = { "ldhq.io" : { fromEmail : "[email protected]", emailBucket : "us-east-1-ldhq.io-ses", emailKeyPrefix : "emails/", forwardMapping : { "[email protected]" : [ "[email protected]" ], "[email protected]" : [ "[email protected]" ] } } }
Installation
Okay, looks like we are all set!
As README claims, all i need to do is to execute single command:
% make
If you did everything right, within a minute or so, Terraform will complete its work.
Check your "./outputs"
folder for DNS Verification Records and SES Credentials.
Updating your Domain DNS Configuration
Lets check DNS Verification Records:
jq . ./outputs/326278417061-us-east-1-dns-records.txt
{
"ldhq.io": {
"dkim-0": {
"name": "<redacted>._domainkey",
"record": "<redacted>.dkim.amazonses.com",
"ttl": "600",
"type": "CNAME"
},
"dkim-1": {
"name": "<redacted>._domainkey",
"record": "<redacted>.dkim.amazonses.com",
"ttl": "600",
"type": "CNAME"
},
"dkim-2": {
"name": "<redacted>._domainkey",
"record": "<redacted>.dkim.amazonses.com",
"ttl": "600",
"type": "CNAME"
},
"verification": {
"name": "_amazonses.ldhq.io",
"record": "<redacted>",
"ttl": "600",
"type": "TXT"
}
}
}
Following records should be set in the DNS configuration for your domain.
More information on how to do that for various Domain providers can be found here.
NOTE: If you are using GoDaddy like me, you need to drop the domain apex from verification record, just like inkplant’s “amazon-ses-godaddy” post noted.
You can check your domain’s records via mxtoolbox or dmarcanalyzer, example:
Once your records propagate, it takes approx ~10 minutes for domain to change status from Pending:
To Verified state:
Email Address setup in Gmail account
Next, its time to update Gmail with following creds:
jq . ./outputs/326278417061-us-east-1-ses-credentials.txt
{
"smtp_server": {
"name": "email-smtp.us-east-1.amazonaws.com",
"port": "587"
},
"[email protected]": {
"email": "[email protected]",
"login": "AKIA<redacted>",
"password": "BLWMr<redacted>"
},
"[email protected]": {
"email": "[email protected]",
"login": "AKIA<redacted>",
"password": "BFans<redacted>"
}
}
Simply follow this part of README to add your new and shiny Email Addresses.
Testing Time!
Lets send an email from "[email protected]"
to some other user:
As you can see, we’ve got it:
People respecting Doge always write a reply. And here is the final result:
Works like charm
Being Free* & Prod-Grade solution
As of time of writing this post, Amazon Billing Dashboard forecasted 0.00 USD for the end of month and reported plenty of Free Tier resources available:
Unless you are sending thousands of mails per day with 4K videos attached (not to worry, limits won’t allow that), you ‘ll probably never pay a dime for months to come.
However!
Serverless Email Service should not be considered Production-Grade solution for Companies larger than ~5-7 users, as budget predictability becomes uncertain and overall control is basically limited.
If your Company or Startup rapidly extends the numbers of employees, in my opinion it’s best to consider paid alternatives provided above.
Anyway, it’s up to you .
Conclusion
In less than 20 minutes, we have created a Serverless Email Service that requires no maintenance and slim-to-none cost!
Target goal achieved
Stay Frosty,
L.