O'Reilly logo

Drupal 8 Module Development by Daniel Sipos

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The mail plugin

So let's start by creating our Mail plugin class, and if you remember, plugins go inside the Plugin folder of our module namespace. Mail plugins belong inside a Mail folder. So this is what a simple skeleton mail plugin class can look like:

namespace Drupal\hello_world\Plugin\Mail;use Drupal\Core\Mail\MailFormatHelper;use Drupal\Core\Mail\MailInterface;use Drupal\Core\Plugin\ContainerFactoryPluginInterface;use Symfony\Component\DependencyInjection\ContainerInterface;/** * Defines the Hello World mail backend. * * @Mail( *   id = "hello_world_mail", *   label = @Translation("Hello World mailer"), *   description = @Translation("Sends an email using an external API specific to our Hello World module.") * ) */class HelloWorldMail implements ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required