7 minute read

Preamble

post-logo-ncp

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:

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


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? :smirk:

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:

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 :smirk:

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:

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:

dkim-check

Once your records propagate, it takes approx ~10 minutes for domain to change status from Pending:

verification-pending

To Verified state:

verification-completed

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:

6-outgoing-email-to-ext-sent

As you can see, we’ve got it:

6-outgoing-email-to-ext-received

People respecting Doge always write a reply. And here is the final result:

6-outgoing-email-to-ext-received

Works like charm :smirk:

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:

pricing

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.

:fire: However! :fire:

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 :slightly_smiling_face:.

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 :wink:

Stay Frosty,

L.