Use Drupal 7 Simplenews to send HTML newsletters with the MimeMail module

Here’s how to send HTML newsletters in Drupal 7 using the Simplenews module in Ubuntu from the ground up. This walk-thru assumes you are working on a laptop and the Drupal webserver is running on a separate VM.

Install Drupal

drush dl drupal-7

Move the resulting drupal-7 directory to its proper location in /var/www and rename as required.

Create a test site in the sites folder.

Install the modules

cd sites/all/modules

drush dl mailsystem

drush dl mimemail

drush dl simplenews

sudo chgrp -R www-data .

Create the database, configure the settings.php file, create the test site conf file in /etc/apache2/sites-available and enable the site. For a test site, using a local DNS entry in your laptop’s hosts file is good enough. But remember to add this entry to the hosts file in Ubuntu to avoid the “Cannot access web pages” status error.

Apply patches

Patch mimemail to fix the Notice: Undefined offset: 0 in mimemail_html_body() error

https://www.drupal.org/project/mimemail/issues/2883745#comment-12566218

Enable modules

Once the site is installed and running, enable the three modules.

Ex.

Go to MailSystem settings and verify the class is MimeMailSystem.

In Mime Mail settings, verify the E-mail format is Full HTML or something equivalent.

In the Newsletters settings, edit the newsletter category.

Set the Email format to HTML.

Set the default for future newsletters to HTML and verify the test email address.

Create a newsletter.

 

Make sure the body contains HTML. <html>ipsum is good for this. Make sure the Text format is Full HTML.

Clear recent log messages. Do this so you can easily see new errors that arise while sending the newsletter.

Send the newsletter to the test address.

Check recent log messages for errors. Unless you have enabled mail logging by some means, you will not see a message for the mail sent. This is OK as the Drupal page confirmation and the received email work just as well. What you care about here are errors. Resolve all of them.

Note: In the Newsletter settings, you may enable logging un the Send mail section.

Verify the received email contains HTML.