How to Send WordPress Multisite Emails with Mailgun

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.

Get Started

  1. Create a Mailgun account
  2. Add your domain (e.g., example.com)
    Add New Domain Mailgun
  3. 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
  4. Once these are added, click Check DNS Records Now
    check_dns_records
    If all goes well, you will see a green Active notice, which indicates that you’ve correctly verified your domain.
  5. Add the Mailgun WordPress plugin to your site
    [button link=”https://wordpress.org/plugins/mailgun/” bg_color=”#ffffff” border=”#676767″ text=”dark” window=”yes”]Mailgun Plugin[/button]
  6. Open your wp-config.php file and enter these six lines:
    define('MAILGUN_USEAPI', true);
    define('MAILGUN_APIKEY', 'key-yourkeyhere');
    define('MAILGUN_DOMAIN', 'mydomain.com' );
    define('MAILGUN_USERNAME', 'postmaster');
    define('MAILGUN_PASSWORD', 'yourMailgunSMTPpasswordhere');
    define('MAILGUN_SECURE', false);
    You can find this information by clicking on Domains and then click on your verified domain
  7. Go back to your WP network admin dashboard and Network Activate the Mailgun plugin.

That’s it.

Now your emails will be sent using Mailgun instead of your server.


Comments

4 responses to “How to Send WordPress Multisite Emails with Mailgun”

  1. Works well across the entire network. Thanks for writing the post!

    1. No problem! Glad you found it useful.

  2. Hello Nathan, Mailgun introduced the MAILGUN_REGION element that need to be defined, and without this the application stop sending emails. Do you know how to add the information to the codes?

  3. Hello, I think I have find the solution. We just need to add a

    define(‘MAILGUN_REGION’, EU);

    line to the wp-config.php file.

Leave a Reply

Your email address will not be published. Required fields are marked *