Table Of Contents
What is Transactional Email
Transactional email is the email sent when something triggered from your Web Application such as resetting the user password.
My WordPress didn’t send email
This is a common problem if you didn’t configure your server to relay email. Configuring the server to send email is hard. How hard it is? You need to pass 6 marks in MailTester to send an email to Gmail. And your email must be sent using SSL/TLS. Instead of sending email using secure communication, a perfect Simple Mail Transfer Protocol (SMTP) server would require you to set DomainKeys Identification Mail (DKIM), Sender Rewriting Scheme (SRS) (If you are sending email from multiple domains), Sender Policy Framework (SPF), Pointer Record (PTR) and also Domain Message Authentication Reporting (DMARC). Apart from that, you have to deal with messy Postfix configuration which you can’t understand at first look of its configuration files. You read it right, files, not file.
What is MailGun
MailGun is a transactional email service. It is a good third party email service which you can use to send your email to any available email without dealing with messy configuration. MailGun can send up to 10,000 emails per month for free and that is why we are suggesting MailGun for your transactional email service. We are not affiliated to MailGun in any way and we are recommending it because it is the best transactional email service we have tried so far. If you don’t want to use MailGun and insisted on sending email from your own server, take a look at our previous post.
Registering to MailGun
When you are registered to MailGun, you need to add your Credit Card. They won’t charge you if you didn’t reach 10,000 emails per month. If you didn’t add your Credit Card, your email is limited to only whitelisted emails (we won’t discuss what it is).
Adding A New Domain To MailGun
To add a new domain, MailGun will ask you to use a subdomain instead of the root domain. In this tutorial, I will show you how to configure MailGun for runcloud.ga domain. As suggested by MailGun, I will be using mg.runcloud.ga.
Configuring DNS Records
After that, you will receive configuration options like the image below.
Don’t freak out! It is an easy setup. MailGun will ask you to add DNS record as shown above. I am a fan of Cloudflare DNS (only the DNS), and I am using their DNS service to manage my runcloud.ga domain. If you are using other DNS Service such as DNSMadeEasy, Digital Ocean DNS, or Linode DNS, this configuration won’t be any different.
After filling out the DNS Records inside Cloudflare, we will get the settings like the image below.
Check DNS Records
After filling in the DNS records, wait for at least 1 minutes (if you are using Cloudflare) and go back to MailGun. You will see a button to check DNS Records. By clicking that button, you should get all green check marks if you do everything right.
Besides that, you can see your domain is active inside MailGun
Creating MailGun Sender Account
To add a sender account, click Manage SMTP Credentials inside MailGun. Fill in the data like the image below.
You can use any username that you want. For me, I simply choose email@example.com. And don’t forget the password. We will use this account in the next step.
WordPress SMTP Plugin
There are plenty of WordPress plugins for SMTP and my suggestion is Easy WP SMTP and SMTP Mailing Queue. What is the different between both plugins? Easy WP SMTP just a plugin to replace default WordPress email sending method. While SMTP Mailing Queue will queue the email and send the email using cronjob. Check out this post on how to enable true cron job and make WordPress faster.
Inside any SMTP plugins that you are using, every plugin won’t differ much in configuration. All of them will ask for SMTP host, encryption, port, and credential. Now fill in the data with the same credential that you have created inside MailGun.
For the host, MailGun uses smtp.mailgun.org. For the port, you can use either 25, 587 or 465.
Some of the plugins that you are using may have a function to test sending email. But if your plugin doesn’t have it, just request a forgot password from WordPress.