XAMPP: Debugging Email Messages

 hints, troubleshoot  Comments Off on XAMPP: Debugging Email Messages
Jul 262015
 

I use XAMPP to host my local pre-staging test environments and I don’t install the Mercury e-mail server since it doesn’t “play nice” with Outlook (or maybe it’s the other way around).  That said, it’s always been a challenge to debug customizations I’m creating that include e-mail changes.

I was recently trolling through my c:/xampp folder and came across c:/xampp/mailoutput.  This folder contains a bunch of mail-*.txt files, one for every email group ever sent from one of my locally-hosted sites!

If a page’s action sent multiple email messages, those messages are concatenated within a single mail-*.txt file.  The beauty of this is that the HTML emails are captured as (er) HTML1 so that you can cut the HTML section out to a new file and display it in your web browser for validation.

Now, I can get rid of all the test-only changes that I’ve made to Zen Cart’s zen_mail function and still debug/validate the email output that’s being generated.


1Unlike the method that Zen Cart uses to store the HTML emails in the database, replacing the HTML tags’ starting (<) and ending (>) characters with an underscore (_) which makes the stored information relatively useless as a means of determining how the message will be viewed.

Testing Email Formatting (with “Live” Data)

 hints, v1.5.0, v1.5.1, zen-cart  Comments Off on Testing Email Formatting (with “Live” Data)
Nov 032013
 

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('<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!

 

Tackling Zen Cart Email Issues

 hints, zen-cart  Comments Off on Tackling Zen Cart Email Issues
Apr 242013
 

I’ve come across a couple of interesting cases where a Zen Cart store’s email either wouldn’t send at all, wouldn’t send HTML emails or wouldn’t send TEXT emails.  For any email-related issues, I always start with this set of FAQs on the Zen Cart site.  If those don’t help, here are a couple of additional hints that might apply:

  1. If a specific type of email (e.g. welcome or order_status) doesn’t send, check to make sure that the EMAIL_SUBJECT value doesn’t contain either carriage-return (\r) or new-line (\n) characters.  The function zen_mail checks those conditions and simply (and silently) fails to send that email as a means of preventing an injection attack on the associated site.
  2. If the email address associated with one of your store’s admin accounts is also used as the email address for a test customer account, that email address will always receive email in the format chosen within the customer account.  For example, if your admin’s Configuration->E-Mail Options->Email Admin Format? is set to TEXT but the admin/test-customer account is set to HTML then that email address will always be sent messages in HTML format.
  3. If you have a multi-language store and neither admin nor customer emails are sent in HTML format for a non-English language … make sure that you have an email template directory associated with those secondary languages.  For example, if your secondary language is Spanish your store should have the directory /email/es that contains all the email template files.  Contrary to what the FAQ page indicates, as of v1.5.1 the zen_mail process does not default to the English version (i.e. the template files present in the /email directory).
  4. If your admin users are not receiving their copy of the various email types that are configured within your admin’s Configuration->E-Mail Options, check to make sure that any multiple email addresses are separated by commas (,).  Sometimes, it’s easy to type a period (.) or semi-colon (;) instead and then none of the emails in the list will receive the message.