There are some automated outgoing emails from my Drupal site like by core system mail, ubercart, webform and Rules.

The reason is that I also have a test site which is exactly the copy of the production site. And I would like to disable all the outgoing emails so that no mails will be sent from the testing one by mistake.

I have installed "phpmailer" "mime mail" "mail editor" modules.

Is there an out-of-box way to do this?

6 Answers 6


The Maillog module is for exactly this purpose, as

Maillog provides an easy possibility to log all Mails for debugging purposes. It's possible to prevent the mails to being sent, so there is no need for an extra mail server to test the mail functionality of other modules or the drupal core.


It would seem to me that you'd want to leave Drupal doing its business logic thing accurately as a production site. Sending Mail (or "logging email") is the mail server's job ... so we just tell the server to not really send the emails.

You can make this a development server configuration value using php.ini sendmail_path value. From this Stackoverflow post you can see how to set it for php.ini. While it cannot go directly into a vhost entry it may go into a directive in your local development enviroment apache configuration as per this ServerFault post.

This way no matter what you do to Drupal, the server never sends email.

<VirtualHost *:80>
    Standard stuff goes here

    <Directory /dir/to/your/web/root>
        php_admin_value sendmail_path "tee mail.out > /dev/null"


Another nice module for this exact purpose is Reroute Email. It allows you to define an email address to send all mail to while active.

This module intercepts all outgoing emails from a Drupal site and reroutes them to a predefined configurable email address.

This is useful in case where you do not want email sent from a Drupal site to reach the users. For example, if you copy a live site to a test site for the purpose of development, and you do not want any email sent to real users of the original site. Or you want to check the emails sent for uniform formatting, footers, ...etc.

This is also a good demonstration of what hook_mail_alter(), available in Drupal 5.x and later, can do.


There is also this nice community page which lists several other possibilities to achieve the same result: Managing Mail Handling for Development or Testing

  • I think this doesn't answer the question. Don't just post links, summarize few points. Commented Oct 5, 2012 at 7:16

There is also MailSystem which can route outgoing emails to TestingSystem.

 * Implements hook_mail_alter
 * it will alter all email sent by drupal
function modulename_mail_alter(&$message) {
  // 'To' field as ''(blank) so it wont send any email 
  $message['to'] = ''; 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.