[Drupal D9–D10 Upgrade] Drupal 10 Symphony Mailer

Suowei Hu
3 min readSep 27, 2023

--

Drupal 9 to 10: migrate from “Swift Mailer” to “Symfony Mailer”

As Drupal 10 is coming around, more and more site will be moving / upgrading to it, and as a part of the Drupal 10 upgrade, drupal module “Swift Mailer” will no longer be supported (https://www.drupal.org/project/swiftmailer), it will be deprecated in the near future and replaced by “Symphony Mailer” (https://www.drupal.org/project/symfony_mailer).

This tutorial provides step-by-step instructions for configuring the “Symfony Mailer” module to correctly send emails, replacing the deprecated “Swift Mailer” module. By following these instructions, you will be able to seamlessly switch to the new replacement and ensure successful email delivery within your Drupal Website.

Prerequisite: To begin with you will need to have a druapl 9 site with swift mailer modules installed and properly configured, and meantime having “Symphony Mailer” installed via composer (or other approaches as you like).

Steps to Migrate from “Swift Mailer” to “Symfony Mailer” as follows

Step-1:

  • To begin with you will need to uninstall the deprecated modules, and then install its replacement (uninstall drupal/swiftmailer and install drupal/symfony_mailer).

Step-2:

Continuing, you will need to make edit on the one of the following files: local.settings.php (or) settings.php . Then add the following email command at the end of the file:

// mailsender command for the "Symfony Mailer" module for drupal 10
$settings['mailer_sendmail_commands'] = [
'/usr/sbin/sendmail -t',
'/usr/sbin/sendmail -bs',
];

//( Command usr/sbin/sendmail will communicates with a locally installed sendmail executable to send the email;
// And "-t", "-st" indicate the operation mode for sendmail executable:
// *"-bs" runs in SMTP mode so theoretically it will act like the SMTP Transport;
// * "-t" runs in piped mode with no feedback, but theoretically faster, though not advised)

(On the official documentation it says you should edit the local.settings.php, however the GovCMS scaffold seems to have its own mechanism of handling this and have local.settings.php listed in the .gitignore file, hence I tried settings.php which also worked sending email no issue)

Step-3:

Lastly, you will need to make changes to the configuration via drupal admin backend, goto “Configuration > System > Mailer” then click on the “transport” tab; You will need to make changes to the transport type “sendmail”, click on “edit”.

Then on the “edit transport” page, change the “command” from “<default>” to “usr/sbin/sendmail -t”. If you are not seeing any of these options, you can try clearing the cache and come back.

Lastly you can goto “Configuration > System > Mailer” then click on the “test” tab, and enter your personal email, testing if the module is functioning correctly.

--

--

Suowei Hu
Suowei Hu

Written by Suowei Hu

Drupal Developer, createing impactful solutions. | Student at Australian National University, an enthusiastic learner. | Github: https://github.com/SuoweiHu