Blog/ How to send HTML emails via SMTP server using HTML Mail and SMTP modules

There are plenty of times when you need to configure your Drupal site to send HTML emails via SMTP server. A common example of an SMTP server is Google apps for business mail. In this blog post, we'll show you how to use HTML Mail module along with SMTP.

1) Download and enable HTML Mail, SMTP Authentication Support and Mail System modules.

Enable HTML Mail, Mail System and SMTP Authentication Support

2) Go to "Configuration" -> "Mail System". Expand the New Class fieldgroup. Select "HTMLMailSystem" in the format() method dropdown and "SmtpMailSystem" in the mail() method dropdown. Save the form.

Setting values for format() and mail() fields

3) Saving the previous form should save in sites/default/files/mailsystem folder. If there is an error, make sure that the files folder is writable by the web server. saved in folder

4) Go to "Configuration" -> "SMTP Authentication Support". Enter SMTP server information. Note that Google uses port number 465 with SSL. Also enter Authentication information, if any. Click the checkbox to allow HTML in the email. Enter Test Email and save the form.

SMTP server, port and protocol details

SMTP Authentication

5) Check your test email. You should have got the following email - Congratulations!! Your SMTP configuration is working.

Drupal SMTP test e-mail

6) Go to "Configuration" -> "HTML Mail" -> "Send Test". Enter some HTML in the email body. Change Test mail sending class to HTMLMailSystem_SmtpMailSystem and save the form.

Sending a test e-mail

7) Check your test email. You should have got the email in HTML format. If yes, then you have successfully configured your Drupal instance to send HTML mails using SMTP.

Final screen

Ready to get started?REQUEST A QUOTE