Set up email sending
Drupal CMS includes a modern, flexible system for handling email, designed to support branded HTML messages and connect securely to the email delivery service of your choice. Some emails are sent automatically, for example when someone creates an account or resets a password; others are triggered by visitors, like submitting a contact form or completing a checkout. This page connects your site to an SMTP provider so those messages deliver reliably.
All outgoing email sent through an SMTP provider, confirmed with a test message. Email sends with the default settings alone, but the built-in option (PHP’s mail function) is often blocked or ignored by modern hosting environments and its messages can land in spam folders. If your delivery service offers its own Drupal integration module, that can be the better path; see the variations below.
Prerequisites
Section titled “Prerequisites”- A running Drupal CMS site with an administrator account.
- An account with an SMTP provider such as Gmail, SendGrid, Mailgun, or Amazon SES. The steps use Gmail; the same instructions apply to any provider once you swap in its connection details.
Gather your SMTP connection information
Section titled “Gather your SMTP connection information”Google requires that you create an App Password in your Google account. Use the Google account matching the email address you want to send from; for most people this matches the address on Configuration → System → Basic site settings/admin/config/system/site-information.
- Visit myaccount.google.com/security.
- Turn on 2-Step Verification, if it is not already enabled.
- Visit myaccount.google.com/apppasswords.
- Choose an App name such as
Drupal CMS. - Select Generate.
- Copy the generated password. It becomes your SMTP password in the next step.
Configure your SMTP credentials in Drupal
Section titled “Configure your SMTP credentials in Drupal”- Go to Configuration → System → Drupal Symfony Mailer Lite
/admin/config/system/symfony-mailer-lite/transport. - Choose SMTP from the Transport type select list, then select Add transport.
- Under the SMTP settings, enter:
- Label:
Gmail SMTP - User name: your full Gmail address
- Password: the 16-character App Password from Google
- Host name:
smtp.gmail.com - Port:
587 - Perform TLS peer verification: on
- Label:
- Save the configuration.
To use a different SMTP provider, replace the host, port, and credentials with its values.
Send a test email
Section titled “Send a test email”- On the same settings page, open the Test tab.
- Enter an email address to test delivery.
- Select Send test email and confirm the message arrives in the inbox.
Set SMTP as the default mailer
Section titled “Set SMTP as the default mailer”To send all emails through SMTP, go to Configuration → System → Drupal Symfony Mailer Lite/admin/config/system/symfony-mailer-lite/transport, locate the SMTP transport in the list, and choose Set as default from the Operations menu.
Verify
Section titled “Verify”Send a test message from the Test tab and confirm it arrives in the inbox. The email log at Reports → Email log/admin/reports/email records each delivery attempt; see Customize system emails.
Variations
Section titled “Variations”Use your provider’s integration module
Section titled “Use your provider’s integration module”Some email delivery services, like SendGrid or Mailgun, offer their own integration modules for Drupal. These are often the most reliable way to set up email, and they may include added features like click tracking, deliverability logs, or template syncing. Before configuring SMTP manually, check whether your provider offers an integration module that works out of the box; see Add features with recommended add-ons for how features are added to your site.
Capture email in development environments
Section titled “Capture email in development environments”During development, you may not want your site sending real emails to real users. Configure your local or staging environments to send messages to a tool like Mailpit instead, so you can review emails without delivering them. DDEV includes Mailpit; open it with ddev mailpit.
To route mail there, override the Symfony Mailer Lite transport configuration in an environment-specific settings file, such as settings.local.php, or with a module like Configuration Split. This example turns the module’s built-in native transport into an SMTP transport that points at DDEV’s Mailpit server, and makes it the default:
// Send all mail to DDEV's Mailpit instead of real inboxes.$config['symfony_mailer_lite.settings']['default_transport'] = 'native';$config['symfony_mailer_lite.symfony_mailer_lite_transport.native']['plugin'] = 'smtp';$config['symfony_mailer_lite.symfony_mailer_lite_transport.native']['configuration']['host'] = 'localhost';$config['symfony_mailer_lite.symfony_mailer_lite_transport.native']['configuration']['port'] = 1025;Another option: add a Null transport through the UI and set it as the default, then configure only your production site to use the SMTP transport.
Related
Section titled “Related”- Customize system emails designs the templates your site sends.
- Create a contact form sends its submissions through this email system.
- The modules behind the email system, on Drupal.org:
easy_emailprovides the interface for managing templates and overrides, Symfony Mailer Lite adds SMTP support using Symfony Mailer, and Mail System assigns mailer and formatter plugins to different parts of Drupal.
Was this page helpful?
Drupal is a registered trademark of Dries Buytaert.