How to use Mailgun with MyMail the newsletter plugin for WordPress?

Please share
Share with your friends








Submit

Like most of you I use MailChimp to publish newsletters and for the management of my mailing list. If the number of subscribers becomes bigger it’s often more lucrative to use a WordPress plugin like MyMail together with a transactional mail service provider. In the past was MyMail and Mandrill an inexpensive combination, but since Mandrill has become a premium add-on for MailChimp, many MyMail users are looking for alternatives.

Setup Mailgun for MyMail

Selecting a new transactional mail service for MyMail

Currently you can choose from the add-on section the following SMTP providers for your MyMail application: Mandrill, Amazon SES and Sendgrid. According the product support there should be an option for Mailgun too, but it’s not done until now. There is also a Mailgun add-on for MyMail on Github, but this doesn’t work with current version of MyMail.

How to install Mailgun for MyMail?

First of all you need a Mailgun account. Get one here (it’s free for the first 10.000 mails/month) and add your sending domain name to that account. The whole process is well documented in your Mailgun account, so I don’t repeat it here. If your ready, you will have the SMTP server information including your credentials on the domain’s settings page. Use this information for the MyMail settings: Dashboard > Newsletter > Settings > Delivery. Choose the tab “SMTP” and enter “smtp.mailgun.org” on port “587” and enter also your SMTP credentials. After saving this settings your screen should look like this:

Mailgun SMTP settings

Above the form named “Delivery Method” is an option to test your SMTP connection.

How about mail bounces?

Handling mail bounces is important because every time you send an email that can’t be delivered, that message is counted for account and a high bounce ratio is bad for your accounts authority. It’s like sending the mail delivery guy to a non existing address over and over again. You can find a list of bounces in your Suppressions list.

List of mail bounces

With the Mandrill add-on it wasn’t necessary to configure the MyMail plugin for mail bounces, because all bounces are reported back to MyMail via Mandrill. Since we use SMTP as the delivery method now, mail bounces need some configuration. You can do this with the mail bounce feature from MyMail (tab “Bouncing”). For this function it’s necessary to forward all bounces to a mailbox where MyMail will “read” these message for further processing. In my personal opinion is this not the best way to handle bounces. Mailgun will collect all bounced email addresses and we need only a simple way to tell MyMail that these addresses need to get off the active subscriber list.

A simple script to process the bounces also in MyMail

The following simple script is maybe a quick and dirty method to handle the mail bounces, but you can use it until the Mailgun add-on for MyMail is released (I’ve read in the comments that the developer has this for more than 1 year on his list!).

The script has two functions: 1) Get the list of all (max. 100 at a time) bounced email address to them to update the status of the subscribers in your MyMail list. 2) Remove the bounced email address from the Mailgun Suppressions list right after the subscriber is updated. The last function is necessary, because otherwise the list will become bigger an bigger.

Place this script on your website and protect the directory with a password. Change the path for the wp-load.php script and the values for the variables $apikey$domain and $mymail_table. You can find your API key on the Mailgun settings page. The value for the variable $mymail_table is a combination of your WordPress table prefix plus “mymail_subscribers”. If you prefix is “wp123_” the table name would be “wp123_mymail_subscribers”. You can run the script in your browser (every time before you like to issue a new newsletter) or you can run a daily CRON job. The script is using functions from the WordPress HTTP API and the new Mailgun Surpression API. 

I will transform this PHP script into a WordPress plugin if the MyMail add-on for Mailgun isn’t released over a couple of weeks. If you have any questions please post them using the comment form.

One thought on “How to use Mailgun with MyMail the newsletter plugin for WordPress?

  1. Hello!
    Thanks for your article on using mailgun with mymail.
    You said:
    >I will transform this PHP script into a WordPress plugin if the MyMail add-on for Mailgun isn’t released over a couple of weeks.
    Let me know if it is ready and how we may get the plugin :)
    Thanks for your attention!

Comment Rules

Don’t post your code here, post your code block or snippet to pastebin and include the pastebin URL in your comment.

I delete all comments with non related links inside the comment text. Don't use keywords for the field of your real name (most people like to use your name for their answer). Keep your comment related to the topic, if your question is off-topic, please use the contact form instead.

Leave a Reply

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

*
*
Website