Setting Up To Send HTML Email
An important aspect of many websites is having the capability to send email to it's members. These emails can be notifications, newsletters, etc. With Drupal you can send email in plain text format or using HTML. Now there is a debate whether plain text format or HTML format is better. There are pros and cons to both. With plain text you get consistency and accessibility across platforms and devices but you can't have images and links which can enhance the user experience. HTML you can track performance like clickthrough rates and apply your brand. A couple of the cons are that spam filters monitor text to HTML ratio and appearance can vary depending on the device it's viewed on. Which to use? Both. My suggestion would be emails such as newsletters you would use HTML and transactional emails would most likely be sent using plain text. To use HTML email we need to add a few modules and do some configuration. So, let's get started.
The modules you will need to add are:
- SMTP Authentication Support
- Mail System
- Mime Mail
Once you have installed them, we then need to configure them. In the Administration menu, click on Configuration and under System you will see all 3 modules there. We will start with SMTP Authentication Support.
SMTP Authentication Support
Configuring this module was not as cut and dry as it appears. I actually had to get a little help from the host of my site. The issue came from the SMTP Server and SMTP Backup Server settings. When I used the mail server name I could send a test email to a domain email account but it would fail when sending to an email outside the domain such as gmail. Obviously this was not the desired outcome. I then tried "localhost" and the same issue occured. I ended up having to use the IP 127.0.0.1 and that cured the problem. You may not encounter any problems using your mail server but I'm just presenting other options if it isn't working properly. The rest of the configuration is pretty simple to follow. Make sure you check the box, Allow to send e-mails formated as Html. Once you are done, send a test email and click Save.
The Mail System module is pretty straight forward. Site-wide default is SmtpMailSystem and Mime Mail module class is the MimeMailSystem.
Some of the settings here depend on preference. You should take a look at the different options to decide what you want to do. Clicking, Send plain text email only, pretty much defeats the purpose of this article since we are setting up for HTML email.
This is pretty much the basic configuration for HTML email. You may need to make adjustments to suit your needs. So now that it's configured, how do we use it? That is for another article.