Last time, when I talked about installing WordPress on AWS LightSail, I mentioned that we do have to setup our own emails. AWS LightSail doesn’t come with an email server but it does come with a plugin called WP-Mail-SMTP.
You can use any SMTP provider and add it to your WordPress install to get the email service. This is a workaround as it doesn’t provide an email capability to your domain.
Like for this blog, I created a gmail account and added it as a SMTP provider, which was handling all the emails. I would like those emails to go from techkle.com rather than gmail.com but that was not the case.
Why Emails Should Be From Domain Name
You can keep using the general solution but there are problems with it. First of all, email for Techkle coming from a gmail address sounds like a spam and many receiving server will treat it like that.
Even gmail doesn’t like sending too many automated emails. So if your wordpress installation sending too many emails in short time, Gmail will block them.
The other option is to install an SMTP server on the AWS LightSail instance and use that for email service like Sendmail. But that uses the same IP address as your blog and it can become tricky in case some receivers are identifying your email as spam. They might block the IP address and it can create issue for your blog, so its better to keep those things separate.
So what are the options? – Here is my setup as of now:
I am using AWS SES (Simple Email Service) for sending emails, using Gmail to receive emails and MailChimp for my email subscriptions
Now it does sound a lot but think about it, Email Subscriptions usually are managed by third party. So we will end up using MailChimp or any other provider anyway. For the other emails, I didn’t found any single solution which works good, so I have decided to split it into send and receive.
Now lets take a look at it one by one. There are few good options to send email out but I decided to go with AWS SES.
AWS SES Setup With LightSail
AWS SES (Simple Email Service) is a email sending service which can be integrated with LightSail. It gives 62000 per month free emails if you are sending them from EC2 instance, I am not sure if that will apply for LightSail. Lightsail is build on EC2 platform but its still separate from your AWS console.
Its not free but even after that, the charges are very reasonable and you will only pay as per your use. AWS charges $0.10 per thousand emails and $0.12 per GB of data out, which comes out very reasonable.
The setup process for SES is also very easy, you need to verify domain or email and setup WordPress to use SES. I would prefer to verify the domain so that you will not have any restriction on the email address.
How To Verify Domain
- Add your domain to SES for Verification
- SES will provide some DNS records, add them in your DNS
- If you are using Amazon Route 53 DNS, SES will be able to do the second step automatically
- SES will give you DKIM (Domain Key Identified Mail) and SPF (Sender Policy Framework) records. I would recommend to add all of them to DNS
- You can skip the MX record as we are not expecting to receive emails at SES
- Once all the records are added and propagated, SES will verify your domain
By default SES will add your account to a sandbox and you will not be allowed to send emails to everyone. You can only send it to verified domain or email address, you need to raise a service request to raise that limit.
Connect WordPress on LightSail To SES
Now you need to connect SES with your WordPress installation on LightSail. To do that you can install a plugin called WP SES, which can move the emails function for WordPress to SES.
After installation of WP SES, setup the sender email and other settings for it. Now you will need the API key and Secret Key for the AWS account.
Create AWS Secret Key
I prefer creating a user and attaching it with SES permissions. You can do that in AWS console with IAM.
- Create a new user and give it a name
- While giving permissions add policies AmazonSESFullAccess and AmazonSESReadOnlyAccess to that user
- Take a note of Access Key and Secret Key
Once you have those keys, enter it on WP SES settings and send an test email to verified email id. If you receive the email than everything is setup correctly.
Once your service request on AWS is complete and your SES account has been moved out of sandbox, you can enable the WP SES in production. This will replace all the wp_email calls with SES email calls and will start sending all the WordPress emails through SES.
Its never good to send email out from an email address which can’t receive emails. If someone decide to reply to your email, you won’t be able to receive it.
There are two ways you can receive the emails, through AWS SES or use email Forwarders.
AWS SES provides a free service to receive any email coming for verified domain or emails. They will provide a MX record which can be added to your DNS and they will start catching the emails.
The only drawback is that they will not deliver it like other email providers. You can save those email on S3 Bucket or send notifications using AWS SNS. It saves the emails in raw format so they will be really hard to read. It is good only if you have an application to process those raw emails and display. Even after that you will paying the charge for S3 usage.
You can also use a AWS Lambda function to format and forward that email. We will take a look at a later stage.
Most of the domain name provider give email forwarding service with domain name purchase. I use Godaddy for most of my domain name purchase and they allow to create 100 email address with forwarding enable.
This means, I can have up to 100 email address on my domain and the emails coming for them will be forwarded accordingly. The only thing you need to make sure is that MX records are setup correctly.
I have created a gmail address and setup email forwarding for my domain email address. This way even if someone wants to reply on the email, I will still receive it.
If you are using AWS route 53 DNS service, you need to add the MX record. Just create new records and add the value given by your domain provider, that will create the email forward.
This way you have a service to send email out and receive emails and both service can be configured to use any SMTP client.
If you are using LightSail, how are you setting up your email service? Let us know in comments.