Categories

(83)
(69)
(8)
(34)
(74)
(149)

Mail in Drupal 8: the built-in system and useful modules

08.08.2018
Mail in Drupal 8: the built-in system and useful modules
Author:

The dream of many website owners is to have the option to send emails on their websites. Of course, it’s possible with Drupal 8, because it has infinite powers. We’ve already discussed how your Drupal 8 website can “speak” multiple languages, cooperate with any third-party systems, connect to any imaginable social media, make your images perfect on any device, engage your users with super interactive menus, win their hearts with high loading speed, let them publish content on the fly, and more! Let's take a closer look at the options for a perfect mail sending setup.

Drupal 8’s mail sending opportunities

The default mail system in Drupal 8

Drupal 8 has a built-in mail system — MailManager, which also serves as a plugin manager. In addition to the basic core mail plugins, web developers can also declare their own plugins that implement two main methods — the format() and the send(). There are important hooks to use when working with the MailManager. The main ones are the hook_mail() for sending emails and the hook_mail_alter() for editing the existing setup.

In addition to the default mail system, there also are contributed Drupal modules that add-in some important things missing in core, or connect various third-party email sending services to your Drupal website.

Some great contributed Drupal 8 modules for mail sending

The Mail System module

This is definitely the most important contributed Drupal 8 module in this area — the Mail System module. It fills in the most noticeable gap of Drupal default mail system by providing an administrative interface and an API for working with Drupal mail. This module is also successfully used in combination with other modules.

The Mail System module lets you configure the default mail system by selecting:

  • the standard plugin for email formatting before sending it
  • the standard plugin for sending an email after formatting it
  • the theme that will render the emails

In addition, you can make module-specific settings by selecting:

  • the module
  • the key for identifying specific mails
  • the formatter plugin
  • the sender plugin

Mail System module in Drupal 8

Integration modules with the example of SendGrid

You could also rely on some popular third-party email services. For instance, consider connecting your Drupal 8 website to a service for transactional and marketing emails — SendGrid, which is trusted by Uber, Spotify, Glassdoor, Airbnb, Yelp and other large companies.

The SendGrid module for Drupal will help you with the integration, after which you will be able to send emails from your Drupal 8 website quickly, reliably and with flexible options. Your emails will be sent via SendGrid cloud-based delivery system with the help of their strong RESTful API.

We have chosen this service as an example, because the Drupal module for it has a fresh stable version as of June. Others include Mailgun, Mandrill, Elastic Email, Sparkpost, PeytzMail, as well as tools like the Swift Mailer library, and so on. All these Drupal third-party integration modules are now in different levels of stability.

The Views Send module

Meet the module that lets you send emails using the power of Views, which is now part of Drupal 8 core. It allows for personalized mass mailing from a View, where each row generates one email.

Using tokens with the Views fields, you can fully personalize your emails. They will have a subject, a body, a recipient's name, email address, and more taken from the View.

The Contact Emails module

Here is another module that adds advanced features to Drupal 8 core — namely, to the core module Contact, which allows users to send email to other users or site administrators via contact forms.

The Contact Emails module brings in such options as sending emails to multiple recipients, using text formats, tokens, and more. You can send as many emails as you wish with different messages.

The Simple Mail module

As the name suggests, the Simple Mail Drupal module makes mail delivery extremely simple, which is great for simple use cases.

With it, you can also queue your emails and manage the queues with the help of another useful module — the Queue UI, which provides a handy user interface for that.

The Reroute Email module

In many cases — for example, when you do some testing — you do not want the users of the site to receive your emails. So it is useful to be able to reroute all outgoing emails to another address. The Reroute email Drupal 8 module will take care of these scenarios.

The HTML Mail module

The HTML Mail module for Drupal 8 adds some theming to your emails. Namely, it lets you theme your email messages in the same way as you theme your website.

To recap

This is just a glimpse at useful modules and opportunities for mail sending in Drupal 8. In addition, there is a very simple way of providing a perfect mail sending system on your website in accordance with all your wishes. Send a short message here to just one recipient — our Drupal web agency! The rest of the magic will be in our hands.

3 votes, Rating: 5

Read also

1

You’re an experienced player in online business and stay here for a long time. Probably, your site was built in days of yore and your functional is outdated. There is a great possibility you’re...

2

Each Drupal release makes it more refined and up-to-date. The latest one offers better architecture, fresh functionality, improved security and other benefits of Drupal 8. It is considered to be...

3

Convenient searching is a keystone of good website navigation and usability. Help your website users always find what they want, and they will lose all the addresses of your competitors,...

4

Sites have truly unlimited opportunities in Drupal 8 — they are not even limited by the “website” concept! They can go far beyond it, and easily exchange data with all imaginable applications....

5

Drupal lets you easily integrate social networks with your website. We have shared a great collection of Drupal social media integration modules in part 1 and 2. Time flies, and we would now like...

Subscribe to our blog updates