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.
AWS SES is a preferred solution in terms of cost of sending emails but if you are running an e-commerce site and want more control on the look and feel of your emails, I have added few additional options which can be used.
Now, let’s 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, you can 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.
AWS SES is one of the cost-effective solutions but does not render much control on the looks of the emails. If you are running an e-commerce site, you may want to format your emails so that user can get the required information.
SendInBlue SMTP is another solution which you can use to send your transactional emails from WordPress. SendInBlue usually used for marketing campaign but they also offer free transactional emails with limits.
You can go to SendINBlue to create a new account. Once you have created a new account and verified your email address, you can select between Marketing Campaign or Transactional Emails.
Most of the time, transactional emails are already active and you can just enter the SMTP setting in WP-Mail-SMTP. They have their own WordPress plugin but I only advise to use it in case you are using it for Marketing Campaign also.
If you see a message that transactional emails are not active then drop an email to their support. You need to let them know what kind of transactional emails you will be sending and they will activate it for you.
Now all emails going through WordPress will use the SendInBlue email server. They usually allow 300 transactional emails per day in their free account, if you need more than that, you can upgrade the plan.
You also need to add the DKIM records to your DNS provider or you can add additional SendInBlue DNS server in your configuration.
They have Transactional email templates which can be edited to give the desired look.
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.