Sending Mail with Drupal: Reliable Email Setup for Business Sites
By Greg Nowak. Updated 31 July 2026.
Drupal email rarely fails in a dramatic, visible way. More often, a password reset never arrives, a promising enquiry lands in spam, or an approval notification disappears between Drupal and the recipient. The website remains online while the business process quietly breaks.
A reliable setup has three distinct jobs: Drupal composes the right message, a mail service accepts and transports it, and recipient systems trust the sender. Treating all three as part of the build makes failures easier to prevent, diagnose, and own.
Start by Mapping the Messages That Matter
Before choosing a module, list every message the site sends: contact-form submissions, account emails, order confirmations, staff alerts, scheduled reports, and custom workflow notifications. For each one, identify its business owner, expected recipient, urgency, and fallback.
A lost newsletter is inconvenient. A missing password reset blocks a user. A missing quote request can cost revenue. Those messages should not automatically receive the same architecture or monitoring.
Keep Composition Separate from Delivery
Drupal core’s mail manager still composes messages through module-specific mail hooks and passes them to a configured mail backend. Custom code can therefore own the subject, body, language, and headers without being tied to one SMTP provider.
$mailManager = \Drupal::service('plugin.manager.mail');
$params = [
'customer_name' => $customerName,
'project_name' => $projectName,
];
$message = $mailManager->mail(
'my_module',
'project_notice',
$to,
$langcode,
$params
);In production code, inject the mail manager service where practical instead of repeatedly calling the global service container. More importantly, do not interpret a successful return value as proof of delivery. Drupal’s API explicitly says that success only means acceptance at PHP level. Confirmation of delivery must come from the transport provider, SMTP responses, bounce handling, or recipient testing.
| Approach | Good fit | Main consideration |
|---|---|---|
| Host mail or sendmail | Local development and low-risk internal messages on a managed server | Limited visibility; responsibility for the mail server and its reputation stays with the hosting team |
| SMTP Authentication Support | Sites needing a straightforward authenticated SMTP relay | SMTP only; provider APIs, webhooks, queues, and richer delivery reporting require additional work |
| Drupal core Symfony mailer backend | Teams evaluating a core transport replacement configured by DSN | Drupal 11 still labels this backend experimental, and it sends the existing core mail model rather than providing a complete HTML-email system |
| Mailer Plus | HTML templates, attachments, embedded images, async delivery, or more advanced integrations | It is a broader mail-system decision; the project is currently minimally maintained and in maintenance-fixes-only status |
A Sensible SMTP Baseline
For many business sites, authenticated SMTP through a dedicated transactional service or an approved organisational relay is the shortest route to reliable delivery. Drupal’s SMTP Authentication Support module bypasses PHP mail(), uses PHPMailer, and supports Drupal 9.5, 10, and 11. Its stable installation line remains:
composer require 'drupal/smtp:^1.4'Configure the SMTP hostname, port, encryption, and credentials through the deployment environment. Do not commit passwords to the repository or export them casually with site configuration. Also confirm the provider’s current authentication policy: possession of a mailbox password does not necessarily mean automated SMTP login is allowed.
Drupal core’s experimental Symfony backend can instead be configured with a DSN-style settings override:
$config['system.mail']['interface'] = [
'default' => 'symfony_mailer',
];
$config['system.mail']['mailer_dsn'] = [
'scheme' => 'smtp',
'host' => getenv('SMTP_HOST'),
'port' => 587,
'user' => getenv('SMTP_USER'),
'password' => getenv('SMTP_PASS'),
'options' => [],
];Use this deliberately, not simply because Symfony sounds newer. If the requirement includes branded multipart messages, attachments, queues, failover, or provider-specific APIs, document those needs first and evaluate a fuller mail architecture.
Use a From Address Your Domain Can Defend
A contact form should not send mail using the visitor’s address in From:. Your Drupal site is not authorised to send on behalf of the visitor’s Gmail, Outlook, or company domain, so that pattern can fail authentication or resemble spoofing.
Use a stable address on a domain you control, such as [email protected], for From:. Put the visitor’s validated address in Reply-To:. Staff can still reply naturally, while SPF, DKIM, and DMARC can authenticate the actual sending identity.
Deliverability Is Infrastructure, Not a Drupal Checkbox
Google’s current Gmail requirements provide a useful minimum even for modest transactional volumes. All senders to personal Gmail accounts need SPF or DKIM, valid forward and reverse DNS, TLS, standards-compliant messages, and a low spam rate. Senders exceeding 5,000 messages per day to Gmail accounts need SPF, DKIM, and DMARC, plus aligned sender identity. Marketing and subscription messages at that volume also require one-click unsubscribe.
For a typical Drupal business site, enable both SPF and DKIM rather than choosing the minimum, then publish DMARC with reporting. When introducing DMARC to an established domain, first inventory every legitimate sender—including the website, CRM, helpdesk, invoicing platform, and newsletter service—to avoid breaking mail elsewhere.
Define a Launch Test That Proves More Than “Sent”
- Trigger each important message from production-like infrastructure.
- Test delivery to Gmail, Microsoft-hosted mail, and at least one organisational mailbox.
- Inspect received headers for SPF, DKIM, and DMARC results.
- Verify the visible sender,
Reply-To, subject, links, language, and plain-text fallback. - Check Drupal logs and provider activity for rejection, authentication, TLS, bounce, or rate-limit events.
- Assign an owner for investigating failures and a fallback for business-critical enquiries.
Repeat the test after hosting migrations, DNS changes, provider changes, module upgrades, and form redesigns. A test email sent once during development is not ongoing assurance.
The right solution is usually the simplest one your team can operate and observe. If email supports sales, account access, customer service, or approvals, give it the same acceptance criteria as the visible website.
If you need a practical review of a Drupal mail flow, talk to Greg about the setup before missed messages become a recurring operations problem.
Related on GrN.dk
- Sending Mail from a Linux Server with Postfix: A Reliable, Relay-First Setup
- CMS Upgrades in 2026: Choosing PHP for WordPress and Drupal
- AI automations need a spend dashboard before the first runaway bill
Need help with this kind of work?
Discuss your Drupal email setup Get in touch with Greg.
Sources
- Log in to post comments