The Mail Redirect module redirects ALL system generated email to a test mail domain or address. This is especially useful when doing site testing which uses a production database which is populated with real email addresses.

Works with any mail generated by drupal_mail() and with included patch applied (D5 only) any module that uses mimemail. Patch not required with D6 or D7.

NOTE: general usage has changed slightly as of 7.x-2.x branch. Please see README file for more details.

General Usage:

Drupal 7

usage:
- in your test site's settings.php set:

$conf = array('mail_redirect_opt' => "domain");
$conf = array('mail_redirect_domain' => "mydomain.com");

OR

$conf = array('mail_redirect_opt' => "address");
$conf = array('mail_redirect_address' => "myaddress@mydomain.com");

Drupal 8

usage:
- in your test site's settings.php set:

$config['mail_redirect.settings']['mail_redirect_opt'] = 'domain';
$config['mail_redirect.settings']['mail_redirect_domain'] = 'mydomain.com';

OR

$config['mail_redirect.settings']['mail_redirect_opt'] = 'address';
$config['mail_redirect.settings']['mail_redirect_domain'] = 'myaddress@mydomain.com'

result:
- input $to: john_smith@about.com
- output $to:
john_smith@mydomain.com
OR
myaddress@mydomain.com

This module was developed for a multi-developer test environment where ongoing development work runs in parallel with the operation of the production site. The developers regularly sync their test site's db to that of the production server. Our general development environment provides numerous sites folders for a mutli-site setup so that each developer has their own local and server based sandboxes for testing and development. As an example:

3 developers: tom, joe, hank

site folders as:
- www.oursite.com (production site)
- oursite.joe (joe's local)
- oursite.tom
- oursite.hank
- joe.oursite.com (joe's server sandbox)
- hank.oursite.com
- tom.oursite.com

Set up subdomains on a shared host account (we use Dreamhost.com) which provides unlimited subdomains and catch-all email accounts.

e.g. mail domains:
- joe.somedomain.com
- hank.somedomain.com

Set each of these up with catch-all mail accounts.

For Joe's local development system (oursite.joe):
- in sites/oursite.joe/settings.php
- defined $conf['mail_redirect_domain'] = 'joe.somedomain.com';

Now, when mail_redirect module is enabled all the site email will redirect to that domain. E.g.:

Janet_Smith@gmail.com -> Janet_Smith@joe.somedomain.com

All mail will be sent to one catch-all account and it is possible to see what email the system has sent out and who they have been sent to.

This project was designed by LiquidCMS and funded by LifeWire, a NY Times Company.

Drupal 6

I have tested my module with alpha8 version of mimemail and it seems to work without requiring the patch - very cool!!

Drupal 6 release funded by ConsumerSearch.com, a NY Times Company.

Drupal 7

Added features in D7 version:
- allow list of addresses to ignore when doing redirect
- silent redirect to simply not send the redirected emails

Drupal 7.x-2.x

Added features in D7 Rel 2.x version:
- support redirecting to a single email address
- NOTE: this changes what is required to be set in your settings.php file. See README file for more details

Drupal 8

Direct rewrite of 7.x-2.x. I'll post an issue for this and once someone replies that they have tested it, I will publish an official release.

Supporting organizations: 
funding, development

Project information

Downloads