What is Mailgun and why would you want to use it on your WordPress network? Like Mandrill, AWS Simple Email Service (SES), and Mailjet, Mailgun is a transactional email service that allows you to offload the complex and frustrating task of email routing and delivery. While you can send emails directly from your WordPress server, this can be 1. risky because you (or your host) could end up labeled as a spam originator, and 2. your mail is less likely to be delivered from a shared IP or server. You know those envelopes you receive with a generic return label or addressed to “current resident”? That’s what your email looks like to other email services if you aren’t using a transactional email service like Mailgun.
I recommend Mailgun to most clients because Mandrill, which is owned by MailChimp, decided to start charging everyone for a MailChimp account even if they were only using the transactional mail service. If you already pay for MailChimp, it may make sense for you to use Mandrill instead of Mailgun. If you don’t already pay for a MailChimp account, it is much cheaper (mostly likely free) to use Mailgun.
In addition, in my experience Mailgun is the easiest to configure, especially for WordPress Multisite. Plus, you get 10,000 free emails per month. Unless you have a really large network, you will get tracking and logging features as well as improved rates of delivery without paying a dime.
- Create a Mailgun account
- Add your domain (e.g., example.com)
- Mailgun will provide you with records to add to your domain: 2 TXT, 1 CNAME, and 2 MX records.
Depending on your domain registrar, this may differ slightly but you will login to GoDaddy or Bluehost or Namecheap, etc., click on Domain Manager. You will then follow the instructions in Mailgun
- Once these are added, click Check DNS Records Now
If all goes well, you will see a green Active notice, which indicates that you’ve correctly verified your domain.
- Add the Mailgun WordPress plugin to your site
- Open your wp-config.php file and enter these six lines:
define('MAILGUN_USEAPI', true);You can find this information by clicking on Domains and then click on your verified domain
define('MAILGUN_DOMAIN', 'mydomain.com' );
- Go back to your WP network admin dashboard and Network Activate the Mailgun plugin.
Now your emails will be sent using Mailgun instead of your server.