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
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.
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.