After replacing just one file - includes/functions/functions_email.php - Admin Welcome Email header got back to normal.

To sum up, the functions_email.php that messes the Admin Welcome Email header in two related ways:

- When adding another language to your cart, Zencart 1.3.9. (and not only the 1.3.8) shows the Stack Error, related to this part of code:

PHP Code:
// Identify and Read the template file for the type of message being sent
    
$langfolder = (strtolower($_SESSION['languages_code']) == 'en') ? '' strtolower($_SESSION['languages_code']) . '/'
- When adding the Newsletter Subscribe for ZC 1.3.9, the header text shows up in disalighment and the button_check_new_version.gif disappears, because it gets automatically a wrong path: includes/languages/english/images/buttons/button_check_new_version.gif (this folder doesn't exist)

I paste here the modified code provided by Newsletter mod (the rest goes like the original ZC file):

PHP Code:
   // eof: body of the email clean-up

      //determine customer's email preference type: HTML or TEXT-ONLY  (HTML assumed if not specified)

// BEGIN newsletter_subscribe mod 1/2
// dmcl1 -- changed to look for format in SUBSCRIBERS table instead of CUSTOMERS
      
if(defined('NEWSONLY_SUBSCRIPTION_ENABLED') && (NEWSONLY_SUBSCRIPTION_ENABLED=='true')) {
        
$subscriber $db->Execute("SELECT count(*) as count FROM " TABLE_SUBSCRIBERS " WHERE email_address = '" zen_db_input($to_email_address) . "'");
        
$subscriber $subscriber->fields['count'];
    
        if (
$subscriber 0) {
          
$customers_email_format_read $db->Execute("select email_format from " TABLE_SUBSCRIBERS " where email_address= '" zen_db_input($to_email_address) . "'");
          
$customers_email_format $customers_email_format_read->fields['email_format'];
        } else {
          
$sql "select customers_email_format from " TABLE_CUSTOMERS " where customers_email_address= :custEmailAddress:";
          
$sql $db->bindVars($sql':custEmailAddress:'$to_email_address'string');
          
$result $db->Execute($sql);
          
$customers_email_format = ($result->RecordCount() > 0) ? $result->fields['customers_email_format'] : '';
        }
      } else {
        
$sql "select customers_email_format from " TABLE_CUSTOMERS " where customers_email_address= :custEmailAddress:";
        
$sql $db->bindVars($sql':custEmailAddress:'$to_email_address'string');
        
$result $db->Execute($sql);
        
$customers_email_format = ($result->RecordCount() > 0) ? $result->fields['customers_email_format'] : '';
      }
// END newsletter_subscribe mod 1/2

      
if ($customers_email_format == 'NONE' || $customers_email_format == 'OUT') return; //if requested no mail, then don't send.
//      if ($customers_email_format == 'HTML') $customers_email_format = 'HTML'; // if they opted-in to HTML messages, then send HTML format

      // handling admin/"extra"/copy emails:
      
if (ADMIN_EXTRA_EMAIL_FORMAT == 'TEXT' && substr($module,-6)=='_extra') {
        
$email_html='';  // just blank out the html portion if admin has selected text-only
      
}
      
//determine what format to send messages in if this is an admin email for newsletters:
      
if ($customers_email_format == '' && ADMIN_EXTRA_EMAIL_FORMAT == 'HTML' && in_array($module, array('newsletters''product_notification')) && isset($_SESSION['admin_id'])) {
        
$customers_email_format 'HTML';
      }

      
// special handling for XML content
      
if ($module == 'xml_record') {
        
$email_html '';
        
$customers_email_format ='TEXT';
      }

      
//notifier intercept option
      
$zco_notifier->notify('NOTIFY_EMAIL_AFTER_EMAIL_FORMAT_DETERMINED');

      
// now lets build the mail object with the phpmailer class
      
$mail = new PHPMailer();
      
$lang_code strtolower(($_SESSION['languages_code'] == '' 'en' $_SESSION['languages_code'] ));
      
$mail->SetLanguage($lang_codeDIR_FS_CATALOG DIR_WS_CLASSES 'support/');
      
$mail->CharSet =  (defined('CHARSET')) ? CHARSET "iso-8859-1";
      
$mail->Encoding = (defined('EMAIL_ENCODING_METHOD')) ? EMAIL_ENCODING_METHOD "7bit";
      if ((int)
EMAIL_SYSTEM_DEBUG $mail->SMTPDebug = (int)EMAIL_SYSTEM_DEBUG;
      
$mail->WordWrap 76;    // set word wrap to 76 characters
      // set proper line-endings based on switch ... important for windows vs linux hosts:
      
$mail->LE = (EMAIL_LINEFEED == 'CRLF') ? "\r\n" "\n";

      switch (
EMAIL_TRANSPORT) {
        case 
'smtp':
          
$mail->IsSMTP();
          
$mail->Host trim(EMAIL_SMTPAUTH_MAIL_SERVER);
          if (
EMAIL_SMTPAUTH_MAIL_SERVER_PORT != '25' && EMAIL_SMTPAUTH_MAIL_SERVER_PORT != ''$mail->Port trim(EMAIL_SMTPAUTH_MAIL_SERVER_PORT);
          
$mail->LE "\r\n";
          break;
        case 
'smtpauth':
          
$mail->IsSMTP();
          
$mail->SMTPAuth true;
          
$mail->Username = (zen_not_null(EMAIL_SMTPAUTH_MAILBOX)) ? trim(EMAIL_SMTPAUTH_MAILBOX) : EMAIL_FROM;
          
$mail->Password trim(EMAIL_SMTPAUTH_PASSWORD);
          
$mail->Host trim(EMAIL_SMTPAUTH_MAIL_SERVER);
          if (
EMAIL_SMTPAUTH_MAIL_SERVER_PORT != '25' && EMAIL_SMTPAUTH_MAIL_SERVER_PORT != ''$mail->Port trim(EMAIL_SMTPAUTH_MAIL_SERVER_PORT);
          
$mail->LE "\r\n";
          
//set encryption protocol to allow support for Gmail or other secured email protocols
          
if (EMAIL_SMTPAUTH_MAIL_SERVER_PORT == '465' || EMAIL_SMTPAUTH_MAIL_SERVER_PORT == '587' || EMAIL_SMTPAUTH_MAIL_SERVER == 'smtp.gmail.com'$mail->Protocol 'ssl';
          if (
defined('SMTPAUTH_EMAIL_PROTOCOL') && SMTPAUTH_EMAIL_PROTOCOL != 'none') {
            
$mail->Protocol SMTPAUTH_EMAIL_PROTOCOL;
            if (
SMTPAUTH_EMAIL_PROTOCOL == 'starttls' && defined('SMTPAUTH_EMAIL_CERTIFICATE_CONTEXT')) {
              
$mail->Starttls true;
              
$mail->Context SMTPAUTH_EMAIL_CERTIFICATE_CONTEXT;
            }
          }
          break;
        case 
'PHP':
          
$mail->IsMail();
          break;
        case 
'Qmail':
          
$mail->IsQmail();
          break;
        case 
'sendmail':
        case 
'sendmail-f':
          
$mail->LE "\n";
        default:
          
$mail->IsSendmail();
          if (
defined('EMAIL_SENDMAIL_PATH')) $mail->Sendmail trim(EMAIL_SENDMAIL_PATH);
          break;
      }

      
$mail->Subject  $email_subject;
      
$mail->From     $from_email_address;
      
$mail->FromName $from_email_name;
      
$mail->AddAddress($to_email_address$to_name);
      
//$mail->AddAddress($to_email_address);    // (alternate format if no name, since name is optional)
      //$mail->AddBCC(STORE_NAME, STORE_OWNER_EMAIL_ADDRESS);

      // set the reply-to address.  If none set yet, then use Store's default email name/address.
      // If sending from contact-us or tell-a-friend page, use the supplied info
      
$email_reply_to_address = (isset($email_reply_to_address) && $email_reply_to_address != '') ? $email_reply_to_address : (in_array($module, array('contact_us',  'tell_a_friend')) ? $from_email_address EMAIL_FROM);
      
$email_reply_to_name    = (isset($email_reply_to_name) && $email_reply_to_name != '')    ? $email_reply_to_name    : (in_array($module, array('contact_us',  'tell_a_friend')) ? $from_email_name    STORE_NAME);
      
$mail->AddReplyTo($email_reply_to_address$email_reply_to_name);

      
// if mailserver requires that all outgoing mail must go "from" an email address matching domain on server, set it to store address
      
if (EMAIL_SEND_MUST_BE_STORE=='Yes'$mail->From EMAIL_FROM;

      if (
EMAIL_TRANSPORT=='sendmail-f' || EMAIL_SEND_MUST_BE_STORE=='Yes') {
        
$mail->Sender EMAIL_FROM;
      }

      if (
EMAIL_USE_HTML == 'true'$email_html processEmbeddedImages($email_html$mail);

      
// PROCESS FILE ATTACHMENTS
      
if ($attachments_list == ''$attachments_list = array();
      if (
is_string($attachments_list)) {
        if (
file_exists($attachments_list)) {
          
$attachments_list = array(array('file' => $attachments_list));
        } elseif (
file_exists(DIR_FS_CATALOG $attachments_list)) {
          
$attachments_list = array(array('file' => DIR_FS_CATALOG $attachments_list));
        } else {
          
$attachments_list = array();
        }
      }
      global 
$newAttachmentsList;
      
$zco_notifier->notify('NOTIFY_EMAIL_BEFORE_PROCESS_ATTACHMENTS', array('attachments'=>$attachments_list'module'=>$module));
      if (isset(
$newAttachmentsList) && is_array($newAttachmentsList)) $attachments_list $newAttachmentsList;
      if (
defined('EMAIL_ATTACHMENTS_ENABLED') && EMAIL_ATTACHMENTS_ENABLED && is_array($attachments_list) && sizeof($attachments_list) > 0) {
        foreach(
$attachments_list as $key => $val) {
          
$fname = (isset($val['name']) ? $val['name'] : null);
          
$mimeType = (isset($val['mime_type']) && $val['mime_type'] != '' && $val['mime_type'] != 'application/octet-stream') ? $val['mime_type'] : '';
          switch (
true) {
            case (isset(
$val['raw_data']) && $val['raw_data'] != ''):
              
$fdata $val['raw_data'];
              if (
$mimeType != '') {
                
$mail->AddStringAttachment($fdata$fname"base64"$mimeType);
              } else {
                
$mail->AddStringAttachment($fdata$fname);
              }
              break;
            case (isset(
$val['file']) && file_exists($val['file'])): //'file' portion must contain the full path to the file to be attached
              
$fdata $val['file'];
              if (
$mimeType != '') {
                
$mail->AddAttachment($fdata$fname"base64"$mimeType);
              } else {
                
$mail->AddAttachment($fdata$fname);
              }
              break;
          } 
// end switch
        
//end foreach attachments_list
      
//endif attachments_enabled
      
$zco_notifier->notify('NOTIFY_EMAIL_AFTER_PROCESS_ATTACHMENTS'sizeof($attachments_list));

      
// prepare content sections:
      
if (EMAIL_USE_HTML == 'true' && trim($email_html) != '' &&
      (
$customers_email_format == 'HTML' || (ADMIN_EXTRA_EMAIL_FORMAT != 'TEXT' && substr($module,-6)=='_extra'))) {
        
$mail->IsHTML(true);           // set email format to HTML
        
$mail->Body    $email_html;  // HTML-content of message
        
$mail->AltBody $text;        // text-only content of message
      
}  else {                        // use only text portion if not HTML-formatted
        
$mail->Body    $text;        // text-only content of message
      
}

/**
 * Send the email. If an error occurs, trap it and display it in the messageStack
 */
      
$ErrorInfo '';
      
$zco_notifier->notify('NOTIFY_EMAIL_READY_TO_SEND');
      if (!(
$result $mail->Send())) {
        if (
IS_ADMIN_FLAG === true) {
          
$messageStack->add_session(sprintf(EMAIL_SEND_FAILED ' '$mail->ErrorInfo$to_name$to_email_address$email_subject),'error');
        } else {
          
$messageStack->add('header',sprintf(EMAIL_SEND_FAILED ' '$mail->ErrorInfo$to_name$to_email_address$email_subject),'error');
        }
        
$ErrorInfo .= $mail->ErrorInfo '<br />';
      }
      
$zco_notifier->notify('NOTIFY_EMAIL_AFTER_SEND');

      
// Archive this message to storage log
      // don't archive pwd-resets and CC numbers
      
if (EMAIL_ARCHIVE == 'true'  && $module != 'password_forgotten_admin' && $module != 'cc_middle_digs' && $module != 'no_archive') {
        
zen_mail_archive_write($to_name$to_email_address$from_email_name$from_email_address$email_subject$email_html$text$module$ErrorInfo );
      } 
// endif archiving
    
// end foreach loop thru possible multiple email addresses
    
$zco_notifier->notify('NOTIFY_EMAIL_AFTER_SEND_ALL_SPECIFIED_ADDRESSES');

    if (
EMAIL_FRIENDLY_ERRORS=='false' && $ErrorInfo != '') die('<br /><br />Email Error: ' $ErrorInfo);

    return 
$ErrorInfo;
  }  
// end function

/**
 * zen_mail_archive_write()
 *
 * this function stores sent emails into a table in the database as a log record of email activity.  This table CAN get VERY big!
 * To disable this function, set the "Email Archives" switch to 'false' in ADMIN!
 *
 * See zen_mail() function description for more details on the meaning of these parameters
 * @param string $to_name
 * @param string $to_email_address
 * @param string $from_email_name
 * @param string $from_email_address
 * @param string $email_subject
 * @param string $email_html
 * @param array $email_text
 * @param string $module
**/
  
function zen_mail_archive_write($to_name$to_email_address$from_email_name$from_email_address$email_subject$email_html$email_text$module$error_msgs) {
    global 
$db;
    
$to_name zen_db_prepare_input($to_name);
    
$to_email_address zen_db_prepare_input($to_email_address);
    
$from_email_name zen_db_prepare_input($from_email_name);
    
$from_email_address zen_db_prepare_input($from_email_address);
    
$email_subject zen_db_prepare_input($email_subject);
    
$email_html = (EMAIL_USE_HTML=='true') ? zen_db_prepare_input($email_html) : zen_db_prepare_input('HTML disabled in admin');
    
$email_text zen_db_prepare_input($email_text);
    
$module zen_db_prepare_input($module);
    
$error_msgs zen_db_prepare_input($error_msgs);

    
$db->Execute("insert into " TABLE_EMAIL_ARCHIVE "
                  (email_to_name, email_to_address, email_from_name, email_from_address, email_subject, email_html, email_text, date_sent, module)
                  values ('" 
zen_db_input($to_name) . "',
                          '" 
zen_db_input($to_email_address) . "',
                          '" 
zen_db_input($from_email_name) . "',
                          '" 
zen_db_input($from_email_address) . "',
                          '" 
zen_db_input($email_subject) . "',
                          '" 
zen_db_input($email_html) . "',
                          '" 
zen_db_input($email_text) . "',
                          now() ,
                          '" 
zen_db_input($module) . "')");
    return 
$db;
  }

  
//DEFINE EMAIL-ARCHIVABLE-MODULES LIST // this array will likely be used by the email archive log VIEWER module in future
  
$emodules_array = array();
  
$emodules_array[] = array('id' => 'newsletters''text' => 'Newsletters');
  
$emodules_array[] = array('id' => 'product_notification''text' => 'Product Notifications');
  
$emodules_array[] = array('id' => 'direct_email''text' => 'One-Time Email');
  
$emodules_array[] = array('id' => 'contact_us''text' => 'Contact Us');
  
$emodules_array[] = array('id' => 'coupon''text' => 'Send Coupon');
  
$emodules_array[] = array('id' => 'coupon_extra''text' => 'Send Coupon');
  
$emodules_array[] = array('id' => 'gv_queue''text' => 'Send-GV-Queue');
  
$emodules_array[] = array('id' => 'gv_mail''text' => 'Send-GV');
  
$emodules_array[] = array('id' => 'gv_mail_extra''text' => 'Send-GV-Extra');
  
$emodules_array[] = array('id' => 'welcome''text' => 'New Customer Welcome');
  
$emodules_array[] = array('id' => 'welcome_extra''text' => 'New Customer Welcome-Extra');
  
$emodules_array[] = array('id' => 'password_forgotten''text' => 'Password Forgotten');
  
$emodules_array[] = array('id' => 'password_forgotten_admin''text' => 'Password Forgotten');
  
$emodules_array[] = array('id' => 'checkout''text' => 'Checkout');
  
$emodules_array[] = array('id' => 'checkout_extra''text' => 'Checkout-Extra');
  
$emodules_array[] = array('id' => 'order_status''text' => 'Order Status');
  
$emodules_array[] = array('id' => 'order_status_extra''text' => 'Order Status-Extra');
  
$emodules_array[] = array('id' => 'low_stock''text' => 'Low Stock Notices');
  
$emodules_array[] = array('id' => 'cc_middle_digs''text' => 'CC - Middle-Digits');
  
$emodules_array[] = array('id' => 'tell_a_friend''text' => 'Tell-A-Friend');
  
$emodules_array[] = array('id' => 'tell_a_friend_extra''text' => 'Tell-A-Friend-Extra');
  
$emodules_array[] = array('id' => 'purchase_order''text' => 'Purchase Order');
  
$emodules_array[] = array('id' => 'payment_modules''text' => 'Payment Modules');
  
$emodules_array[] = array('id' => 'payment_modules_extra''text' => 'Payment Modules-Extra');
  
/////////////////////////////////////////////////////////////////////////////////////////
  ////////END SECTION FOR EMAIL FUNCTIONS//////////////////////////////////////////////////
  /////////////////////////////////////////////////////////////////////////////////////////


/**
 * select email template based on 'module' (supplied as param to function)
 * selectively go thru each template tag and substitute appropriate text
 * finally, build full html content as "return" output from class
**/
  
function zen_build_html_email_from_template($module='default'$content='') {
    global 
$messageStack$current_page_base;
    
$block = array();
    if (
is_array($content)) {
      
$block $content;
    } else {
      
$block['EMAIL_MESSAGE_HTML'] = $content;
    }
    
// Identify and Read the template file for the type of message being sent
    
$langfolder = (strtolower($_SESSION['languages_code']) == 'en' or 'pt') ? '' strtolower($_SESSION['languages_code']) . '/';
    
$template_filename_base DIR_FS_EMAIL_TEMPLATES $langfolder "email_template_";
    
$template_filename DIR_FS_EMAIL_TEMPLATES $langfolder "email_template_" $current_page_base ".html";

    if (!
file_exists($template_filename)) {
      if (isset(
$block['EMAIL_TEMPLATE_FILENAME']) && $block['EMAIL_TEMPLATE_FILENAME'] != '' && file_exists($block['EMAIL_TEMPLATE_FILENAME'] . '.html')) {
        
$template_filename $block['EMAIL_TEMPLATE_FILENAME'] . '.html';
      } elseif (
file_exists($template_filename_base str_replace(array('_extra','_admin'),'',$module) . '.html')) {
        
$template_filename $template_filename_base str_replace(array('_extra','_admin'),'',$module) . '.html';
      } elseif (
file_exists($template_filename_base 'default' '.html')) {
        
$template_filename $template_filename_base 'default' '.html';
      } else {
        if(isset(
$messageStack)) $messageStack->add('header','ERROR: The email template file for (' $template_filename_base ') or (' $template_filename ') cannot be found.','caution');
        return 
''// couldn't find template file, so return an empty string for html message.
      
}
    }

    if (!
$fh fopen($template_filename'rb')) {   // note: the 'b' is for compatibility with Windows systems
      
if (isset($messageStack)) $messageStack->add('header','ERROR: The email template file (' $template_filename_base ') or (' $template_filename ') cannot be opened''caution');
    }

    
$file_holder fread($fhfilesize($template_filename));
    
fclose($fh);

    
//strip linebreaks and tabs out of the template
//  $file_holder = str_replace(array("\r\n", "\n", "\r", "\t"), '', $file_holder);
    
$file_holder str_replace(array("\t"), ' '$file_holder);


    if (!
defined('HTTP_CATALOG_SERVER')) define('HTTP_CATALOG_SERVER'HTTP_SERVER);
    
//check for some specifics that need to be included with all messages
    
if (!isset($block['EMAIL_STORE_NAME']) || $block['EMAIL_STORE_NAME'] == '')     $block['EMAIL_STORE_NAME']  = STORE_NAME;
    if (!isset(
$block['EMAIL_STORE_URL']) || $block['EMAIL_STORE_URL'] == '')       $block['EMAIL_STORE_URL']   = '<a href="'.HTTP_CATALOG_SERVER DIR_WS_CATALOG.'">'.STORE_NAME.'</a>';
    if (!isset(
$block['EMAIL_STORE_OWNER']) || $block['EMAIL_STORE_OWNER'] == '')   $block['EMAIL_STORE_OWNER'] = STORE_OWNER;
    if (!isset(
$block['EMAIL_FOOTER_COPYRIGHT']) || $block['EMAIL_FOOTER_COPYRIGHT'] == ''$block['EMAIL_FOOTER_COPYRIGHT'] = EMAIL_FOOTER_COPYRIGHT;
    if (!isset(
$block['EMAIL_DISCLAIMER']) || $block['EMAIL_DISCLAIMER'] == '')     $block['EMAIL_DISCLAIMER']  = sprintf(EMAIL_DISCLAIMER'<a href="mailto:' STORE_OWNER_EMAIL_ADDRESS '">'STORE_OWNER_EMAIL_ADDRESS .' </a>');
    if (!isset(
$block['EMAIL_SPAM_DISCLAIMER']) || $block['EMAIL_SPAM_DISCLAIMER'] == '')   $block['EMAIL_SPAM_DISCLAIMER']  = EMAIL_SPAM_DISCLAIMER;
    if (!isset(
$block['EMAIL_DATE_SHORT']) || $block['EMAIL_DATE_SHORT'] == '')     $block['EMAIL_DATE_SHORT']  = zen_date_short(date("Y-m-d"));
    if (!isset(
$block['EMAIL_DATE_LONG']) || $block['EMAIL_DATE_LONG'] == '')       $block['EMAIL_DATE_LONG']   = zen_date_long(date("Y-m-d"));
    if (!isset(
$block['BASE_HREF']) || $block['BASE_HREF'] == ''$block['BASE_HREF'] = HTTP_SERVER DIR_WS_CATALOG;
    if (!isset(
$block['CHARSET']) || $block['CHARSET'] == ''$block['CHARSET'] = CHARSET;
    
//  if (!isset($block['EMAIL_STYLESHEET']) || $block['EMAIL_STYLESHEET'] == '')      $block['EMAIL_STYLESHEET']       = str_replace(array("\r\n", "\n", "\r"), "",@file_get_contents(DIR_FS_EMAIL_TEMPLATES.'stylesheet.css'));

// BEGIN newsletter_subscribe mod 2/2
// Since many templates are Dear So-and-So we need something here when we direct-mail subscribers, as they have no name.
    
if(defined('NEWSONLY_SUBSCRIPTION_ENABLED') && (NEWSONLY_SUBSCRIPTION_ENABLED=='true'))
      if (empty(
$block['EMAIL_FIRST_NAME']) && empty($block['EMAIL_LAST_NAME']))
        
$block['EMAIL_LAST_NAME'] = TEXT_SUBSCRIBER_DEFAULT_NAME;
// END newsletter_subscribe mod 2/2

    
if (!isset($block['EXTRA_INFO']))  $block['EXTRA_INFO']  = '';
    if (
substr($module,-6) != '_extra' && $module != 'contact_us')  $block['EXTRA_INFO']  = ''
It seems to be some minor modification...

I really need this Newsletter add-on to work properly.

So, if you have clue, please tell me.