AWS LightSail WordPress Server does not come with an email server. So you can’t send email on AWS LightSail server by default. Here is how you can configure Email service on your AWS LightSail WordPress Server.
Last time, when I talked about installing WordPress on AWS LightSail, I mentioned that we do have to set up 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 an SMTP provider, which was handling all the emails. I would like those emails to go from Metablogue.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 MetaBlogue coming from a Gmail address sounds like a spam and many receiving servers 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 an issue for your blog, so it’s better to keep those things separate.
So what are the options? – Here is my setup as of now:
Now it does sound a lot but thinks about it, Email Subscriptions usually are managed by the 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 an email out but I decided to go with AWS SES.
AWS SES Setup With LightSail
AWS SES (Simple Email Service) is an email sending service which can be integrated with LightSail. It gives 62000 per month free emails if you are sending them from EC2 instance, but that will not apply for LightSail. Lightsail is built on an EC2 platform but it’s still separate from your AWS console.
It’s 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
- Go To Amazon AWS SES Service.
- Add your domain to SES for Verification
- SES will provide some DNS records, add them to 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 adding 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 the verified domain or email address, you need to raise a service request to raise that limit.
So go to AWS Support Center and create a new case. You can choose the category as “SES Sending Limit” and case type as “Service Limit”. Select the subject as “Limit Increase: SES Sending Limits”, provide additional detail and submit the support ticket.
AWS support team usually takes a day or two to review and approve the SES email sending limit increase.
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, set up 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 a test email to verified email-id. If you receive the email then everything is set up correctly.
Once your service request on AWS is complete and your SES account has been moved out of the 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 an email out from an email address which can’t receive emails. If someone decides 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 an 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 those emails like any other email provider. You can either 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 be paying a charge for S3 usage.
You can also use an AWS Lambda function to format and forward that email. We will take a look at it in a different blog post.
Most of the domain name provider give email forwarding service with domain name purchase. I use Namecheap for most of my domain name purchase and they allow to create 100 email address with forwarding enabled.
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 set up email forwarding for my domain email address. This way even if someone wants to reply to 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 an email out and receive emails. Both services 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.