When you’re working on your admin-level email formatting in a test installation with otherwise “live” date (i.e. copies of “real” customers and their orders) you don’t want your test emails to deluge your customer base! I was digging through /includes/functions/functions_email.php last month and came across the constant DEVELOPER_OVERRIDE_EMAIL_ADDRESS.
If that variable is defined, then all email (both customer and admin) will be sent only to the email address(es) you’ve specified! The value is a packed, comma-separated of email addresses in the format
<Name-to-use>email_address[,<Name-to-use-2>email_address_2 …]
When I’ve used this trick, I created two files:
- An auto-loader (/MY_ADMIN/includes/auto_loaders/config.developer_override_email_address.php) that contains:
<?php
if (!defined('IS_ADMIN_FLAG')) {
die('Illegal Access');
}
$autoLoadConfig[200][] = array(
'autoType' => 'init_script',
'loadFile' => 'init_developer_override_email_address.php');
- An initialization file (/MY_ADMIN/includes/init_includes/init_developer_override_email_address.php) that contains:
<?php
define('DEVELOPER_OVERRIDE_EMAIL_ADDRESS', 'me@example.com);
// -----
// For testing purposes, if the following define is non-blank then it is used as the email address for *all*
// emails. Put up a notice to let the admin know that this override is active, if set.
//
if (defined('DEVELOPER_OVERRIDE_EMAIL_ADDRESS') && DEVELOPER_OVERRIDE_EMAIL_ADDRESS != '') {
$messageStack->add(sprintf('<strong>Notice</strong>: Email address override is active! All emails will be sent to %s.', DEVELOPER_OVERRIDE_EMAIL_ADDRESS));
}
Just change the me@example.com to your email address and it’s set; set the value to ” to disable the feature. A message will appear in your admin’s header if the feature is active, notifying you where all the emails will be sent.
Happy testing!