Managing mail on a local server

Last updated on
3 April 2025

During development the local server should not send email over the internet. This page lists Drupal modules and mail servers that can be configured so that email remains on your local server.

The recommended Drupal local development tool DDEV includes Mailpit mail catcher.

Modules that manage email

Devel Mail Logger

Provides a way prevent outgoing emails from being sent and logs them to the database. It also has an Admin UI to view logged mails.

Drupal Symfony Mailer Log

Provides an easy possibility to log all mails for debugging purposes.

Mail Safety

A simple and safe way to test and debug outgoing emails without having to worry that all your users will get unwanted emails.

  • A dashboard that catches and logs all outgoing e-mails
  • Protect your development, test and staging environments by catching e-mails
  • Able to view all emails that are caught by Mail Safety
  • Debug all mails and see their options and structure
  • Able to send the caught e-mails to their original recipient
  • Able to redirect a caught e-mail to a specific recipient
  • Able to redirect all e-mails to a specific recipient

Reroute Email

It intercepts all outgoing emails and reroutes them to an address you specify. This is very useful in development when you have a copy of a live site with thousands of users, and modules that send emails (e.g. subscriptions), so the email does not go to real users from the copy site. You can also add debug info in the email, if you wish, via a theme function.

SMTP Authentication Support

This module allows Drupal to bypass the PHP mail() function and send an email directly to an SMTP server. The module supports SMTP authentication and can even connect to servers using SSL, if supported by PHP.

PHPMailer SMTP

Send emails via SMTP using the latest PHPMailer library. It aims to be RFC compliant and robust, leaving the heavy lifting to the PHPMailer library. It supports debugging and advanced SMTP configuration such as setting the envelope sender via the UI.

Shared Email Module

This overrides the 'user' module's validation that prevents the same email address being used by more than one user. Works for both registration and account updates. Displays a warning to the user that they are using a shared email.

Mail servers

Mailpit

Mailpit is included in the recommended Drupal local development tool DDEV. It's a mail catcher that’s configured to capture and display emails sent by PHP in the development environment. About Mailpit in DDEV.

MailCatcher

MailCatcher is a simple SMTP server that can catch all emails sent by various systems including PHP. Such emails can then be viewed from MailCatcher's web interface which is available at https://localhost:1080/ by default. Briefly, setup involves two steps:

  1. Install the MailCatcher Ruby gem: sudo gem install mailcatcher
  2. Tell PHP to use MailCatcher for sending emails. On Unix-like systems, this can be done by setting the sendmail_path PHP configuration directive to /usr/bin/env catchmail -f from@domain

More detailed setup instruction is also available. Servers for Hackers has a good tutorial for Ubuntu/Debian users.

Help improve this page

Page status: No known problems

You can: