Configuration

Last updated on
7 October 2019

Drupal 7 will no longer be supported after January 5, 2025. Learn more and find resources for Drupal 7 sites

Please go to 'admin/config/people/swiftmailer' to configure the Swift Mailer module.

The module requires you to download the Swift Mailer library separately to a directory of your choice (relative to the Drupal installation). However, it is advised that libraries are kept in the 'sites/all/libraries' directory. If you keep the Swift Mailer library in 'sites/all/libraries/swiftmailer', then you need to configure the module to look for the Swift Mailer library in that directory.

After the module has been configured with the Swift Mailer library you are advised to make sure that the Swift Mailer library sends e-mails using the right transport option. You can choose between SMTP, sendmail (or any other locally installed MTA) and PHP's mail() function. Please observe the various configuration options which are available for each of the transport options.

Tip! You are advised to configure Swift Mailer to send e-mails using a locally installed MTA if performance is a concern. A locally installed MTA will most often accept e-mails right away and queue them up for sending. Your users will thus not have to wait for an SMTP server to respond back with whether the e-mail will be sent or for some reason was rejected.

You also have the chance to decide whether e-mail messages should be sent as plain text or HTML by default. Swift Mailer will also, if configured, respect any e-mail format dictated by the e-mail. Furthermore, you can also configure the character set which is to be used as default. You are advised not to change any of these options if you are uncertain about what they mean.

Finally, you can test whether the Swift Mailer library sends e-mail messages correctly when the module has been configured and you are ready to put it into action.

Temporary instructions for Drupal 8

Drupal 8 requires that the SwiftMailer library is installed with composer so that it can loaded with the PSR4 autoloader. The good news is that - assuming that you have composer installed - it is all very simple and automatic.

Cryptic instructions for installing SwiftMailer using drush and composer:

  1. drush @mysite dl composer_manager-8.x-1.x-dev swiftmailer-8.x-1.x-dev
  2. drush @mysite up drupal-8.0.x-dev to avoid
    [RuntimeException]                                                                                         
      The .git directory is missing from <drupal-root>/vendor/jcalderonzumba/mink-phantomjs-driver
  3. cd <drupal-root> && php modules/composer_manager/scripts/init.php
  4. composer drupal-update
  5. Works with the simplenews module. (drush @mysite dl simplenews)

Note for D8: In order to make your twig file used when to send the system emails like (welcome, reset password messages ...etc) you may want to uncheck this option (Respect provided e-mail format) from this path /admin/config/swiftmailer/messages .

Help improve this page

Page status: No known problems

You can: