Change record status: 
Project: 
Introduced in branch: 
10.2.x
Introduced in version: 
10.2.0
Description: 

The Symfony mailer component has been added as a composer dependency. All supported transports are accessible via an experimental mail plugin which can act as a drop-in replacement for the existing default php mail plugin.

Administrators may switch to the new mail plugin using the contrib Mail System module. Or alternatively overriding the config from settings.php:

$config['system.mail']['interface'] = [ 'default' => 'symfony_mailer' ];

In order to configure the transport DSN, specify its components in the mailer_dsn config. The following examples may serve as a starting point:

  • For the default sendmail transport:
    $config['system.mail']['mailer_dsn'] = [
      'scheme' => 'sendmail',
      'host' => 'default',
    ];
    
  • For mailpit on localhost:
    $config['system.mail']['mailer_dsn'] = [
      'scheme' => 'smtp',
      'host' => 'localhost',
      'port' => 1025,
    ];
    
  • For authenticated SMTP:
    $config['system.mail']['mailer_dsn'] = [
      'scheme' => 'smtp',
      'host' => 'smtp.example.com',
      'user' => 'some-username@example.com',
      'password' => 'correct horse battery staple',
      'options' => [
        'local_domain' => 'example.org',
      ],
    ];
    

Note that an initial implementation shipping with Drupal 10.2.0-beta1 specified mailer_dsn as an URI-like string. That form allowed to supply multiple transports in a High Availability or Load Balancing configuration. From Drupal 10.2.0-beta2 onwards, those advanced use cases are not supported anymore out-of-the-box. In return, the configuration of the standard case becomes much simpler.

Impacts: 
Site builders, administrators, editors

Comments

ressa’s picture

Thanks for the update, what would a non-SMTP set up look like? DDEV maintainer @stasadev just helped me allow Postmark to bypass Mailpit in DDEV, see Document how to bypass Mailpit and allow Postmark to send email #5606. Will this method still work in Drupal 10.2, or does it need tweaking?

ressa’s picture

My solution to send HTML emails via Postmark (using REST), without installing https://www.drupal.org/project/postmark/ was to install Drupal Symfony Mailer and then configure a transport. See Drupal Symfony Mailer > FAQ / tips > Send mail with Postmark.

About intercepting or allowing mail to get sent in DDEV during development, the easiest method is to switch the Mailer transport default to "SMTP/Sendmail", since these should get intercepted by Mailpit in DDEV.