Recently Updated

My Services

Blog: Testing Email Formatting (with "Live" Data)

Nov032013

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:

  1. 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');
  2. 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('Notice: 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!

Copyright © 2012-2021 Vinos de Frutas Tropicales. Powered by Zen Cart