Skip to main content
Image
Untitled%20design%20%2811%29.jpg

How to Customise Emails with Drupal 8

article publisher

Jayati

Drupal

In the 18 years-long journey, Drupal has evolved in many aspects from responsive Bartik to decoupled Drupal. With every new release, the Drupal community comes up with impressive new modules and improvements in the existing ones. However, emails haven’t seen the light of the day in the last decade from Drupal. The emails that we send out are still the same via its robust system. 

Being on the backseat from a long time, we have tried to bring them to the forefront in this blog with modules that can help you send HTML emails in Drupal 8. We will be looking at the following issues from the perspective of making emails customizable in Drupal 8:

  • Inconsistency in the editing process and experience between various modules
  • Absence of HTML formatting 
  • No provision for email history or logs
  • Limitation in features
  • Unable to do attachments and images
blue mail box in the lawn

Making Emails Amazing 

Often developers face situations where they have to send custom HTML formatted emails from the Drupal 8 website and they get stuck with it. One of the major issues being unable to meet the expectations of clients and customers in this fast-pacing 2019. An email needs to be configured with the following features: 

  • A custom responsive design that syncs the theme of your brand
  • Swift provision with images and attachments
  • Customized web fonts
  • Templated headers and footers
  • Custom preview text for display in the inbox
  • A plain text version 
  • Admin-accessible logs of sent emails

Addressing the above-mentioned issues, let’s examine a few modules on these parameters and be our own judges of how we can resolve them. 

The HTML Mail Module

This module lets you theme your messages the same way you theme the rest of your website. In Drupal 7, you can go from plain text emails to HTML-formatted ones easily with this module. The module available in Drupal 8 is in alpha version. Moreover, it integrates well with the Echo and Mail MIME modules. 

Amazon SES

For those who use Drupal’s native mail system, this module can be used to send emails via Amazon SES. The module doesn’t need to set up the SMTP server and demands less configuration. You can just set up the AWS credentials to initiate sending emails via Amazon SES by directly calling API. 

SendGrid Integration

With the basic agenda to handle the delivery of messages, this module offers a flexible way of sending emails out of Drupal. It provides a cloud-based email delivery services to push emails using their Web API (RESTful) that eliminates slow SMTP transactions and leads to quick transactions. The mechanism works on strong market-leading statistics for inbox penetration and an advanced API. 

Furthermore, Drupal Commerce lends you the ability to send triggered marketing emails and track revenue and sales generated by the newsletters.

Message Module templates

Not entirely dedicated to emails, this module is the core of the message stack that enables logging and displaying system events in a number of different use cases. It provides a generic solution for storing a specific kind of message and records events called activity streams. 

  • Following are the features the modules offer: 
  • Exportable and Fieldable message types
  • Support for display (view) modes
  • Multilingual support
  • Token support
  • Entity cache support
  • Template support
  • API hooks
  • Example module included
  • But it comes along these Issues too:
  • It needs integration code for the different template you wanna use because Drupal core doesn't know anything about the message module. 
  • Template editor experience isn't great 
  • Email history without formatting. 

Mailjet

An all-in-one solution, Mailjet allows you to send, track and deliver both marketing and transactional emails. With a unique and highly scalable infrastructure, it can optimize email deliverability with deft. To access the module, an easy-to-use online drag-and-drop interface can be incorporated or you can relay APIs or SMTP that allows developers to integrate its features within their online app or service. 

Features: 

  • Improved deliverability with supporting infrastructure can help you optimize maximum insights from marketing and transactional emails.
  • Mailjet allows you to sync your contacts with one click. 
  • Advanced segmentation feature permits personalized messages for your client base
  • A real-time dashboard that gives access to campaign statistics(who opened, clicked, bounced or unsubscribed from your mailings, create graphs, export data and much more)
  •  Without much coding, you can use the drag-and-drop (WYSIWYG) template builder to create visually-arresting newsletters
  • Based on customer behavior, you can set up triggered email events with Drupal Commerce. 
  • Marketing newsletter and their real-time ROI stats can be gained (only with Drupal commerce).
  • Gauging parameters like types of message, IP reputations, the module selects the best IP address available. 
  • Identify and filter undesirable recipients, like auto-blocking of spam addresses can be achieved with numerous tools that qualify your email base
  • 24/7 customer support available in English, French, German and Spanish

MailChimp

MailChimp is a popular email delivery service and Drupal avails a module that can be integrated for easy access to the website users or visitors. You can generate and send MailChimp email campaigns from your site along with viewing the history of emails sent from MailChimp. With an efficient infrastructure, it allows Drupal to bypass the PHP mail() function and send emails directly to an SMTP server. 

Features:

  • It provides all of the API integration functionality, and the ability to add MailChimp API key and configure a few options. 
  • You can display subscription forms or status for Lists on entities
  • It allows you to map entity fields to your MailChimp merge fields, including mapping fields on Field Collections and internal values on.
  • You can use Views Bulk Operations to create Mailchimp List Segments
  • It supports SMTP authentication and connects to servers using SSL if supported by PHP.

The PHPMailer Module

Another module that enables HTML emails with Drupal, PHPMailer module supports improved bulk-mail performance through SMTP keep-alive connections. With a built-in email rerouting option, the module uses the PHPMailer library itself. 

Features: 

  • You can add attachments to your emails with this module 
  • Already embedded in the SMTP module, it supports external SMTP servers too. 
  • It enables you to send out mixed emails
  • It lets you extend the core functionality by integrating it with the Mime Mail component module too.

The Mime Mail Component Module

The module takes care of your site's style by automatically including your theme's stylesheet files in a themeable HTML message format. Unlike other modules, it’s a “component module” used for boosting other modules’ functionality. It provides simple system actions and Rules actions to send HTML email with embedded images and attachments. 

Features: 

  • You can theme your messages with a specific mail key 
  • The module permits users to receive HTML email and the mail functionality accepts an HTML message body, mime-encodes it and sends it.
  • If the HTML has embedded graphics, these graphics are MIME-encoded and included as a message attachment.
  • If the recipient's preference is available and they prefer plaintext, the HTML will be converted to plain text and sent as-is. Otherwise, the email will be sent in themeable HTML with a plaintext alternative.
  • Converts CSS styles into inline style attributes.

Swift Mailer Module

Most opted for and recommended module, the Swift Mailer is a PHP library for sending HTML and multi-party emails. It delegates all email handling to the Swift Mailer library and extends the basic email sending functionality. Thus, the Swift Mailer library gives access to the following features: 

  • You can send emails directly through an SMTP server of your choice, a locally installed MTA agent such as Sendmail.
  • You can add file attachments and inline images to emails. 
  • It lets you theme emails that reflect a general look and feel of your site. 
  • The module makes you attach images required by the theme to the email and displayed inline.
  • It integrates key services with Drupal  like Mandrill, SendGrid  right out of the box

Easy Mail

With bare minimum coding required, the easy email module is an HTML email system for Drupal 8. The module makes it possible to configure with a robust set of features:

  • Easy Email templates currently support the following features:
  • Drupal mail override system that makes it easy with Drupal core and other modules. 
  • As the templates in Easy mail are fieldable, you need to add custom fields for most use cases. 
  • You can automatically link logged emails to the user accounts and find all the emails sent to that particular user. 
  • It comes with a token replacement for all fields. 
  • You can use standard lifecycle hooks to alter or extend email processing: hook_entity_presave(), hook_entity_update(), etc
  • With this module, you can use tokens or relative paths to specify attachments
  • A full view of sent emails with email log
  • Token replacement for all fields
  • To, CC, and BCC recipients, sender name, address, and reply-to address

Future Roadmap

With easy email module, Drupal community has charted out a roadmap that will enhance its capabilities further. Here are the expected advances: 

  • The storage of sent emails can be made optional by disabling email logging per template as too much database can become too heavy. 
  • The ability to save only emails in the log newer than a fixed amount of days can be added to help manage the growth of the data.
  • The inline images can be made easier in the process of adding them to the templates. 

Conclusion

Among so many options and different methods to send emails through Drupal 8, it’s upon you what fits you the best. So, step out your emails from the closet and make them richly formatted HTML emails to serve the best customers’ experiences. 

OpenSense Labs believe in incorporating the best of modules with your Drupal sites that empower your database and experience. Contact us at [email protected]

Subscribe

Ready to start your digital transformation journey with us?

Related Blogs

SDC: Integrating Storybook & Single Directory Component

Integrating SDC With Storybook OpenSense Labs

Today, we will talk about about Drupal Single Directory Components or SDC and Storybook. Single Directory Components in Drupal allows you…

RFP: How To Create An RFP For Open Source Solutions?

RFP OpenSense Labs

A good Request for Proposals (RFP) or Call for Proposals (CFP) clearly states the goals and expectations of your project and sets the…

Drupal 7 End Of Life: Top Reasons You Should Migrate To Drupal 10

Drupal 7 End Of Life Cover Image OpenSense Labs

Drupal 10 was released in December 2022 and ever since, the community has been pushing its users to do Drupal 7 to 10 migration. As per…