Zen Cart Logo
Forums / Bug Reports / [Done 1.3.5] includesfunctionsfunctions_email.php line 137

[Done 1.3.5] includesfunctionsfunctions_email.php line 137

Locked

Views: 2,091

Results 1 to 3 of 3
This thread is locked. New replies are disabled.
28 Sep 2006, 3:11 PM
#1
skelly avatar

skelly

New Zenner

Join Date:
Sep 2006
Posts:
5
Plugin Contributions:
0

[Done 1.3.5] includesfunctionsfunctions_email.php line 137

Please change includes\functions\functions_email.php line 137 from:

        if (EMAIL_SMTPAUTH_MAIL_PORT != '25' & EMAIL_SMTPAUTH_MAIL_PORT != '') $mail->Port = EMAIL_SMTPAUTH_MAIL_PORT;

To:

        if (EMAIL_SMTPAUTH_MAIL_PORT != '25' && EMAIL_SMTPAUTH_MAIL_PORT != '') $mail->Port = EMAIL_SMTPAUTH_MAIL_PORT;
28 Sep 2006, 3:33 PM
#2
skelly avatar

skelly

New Zenner

Join Date:
Sep 2006
Posts:
5
Plugin Contributions:
0

Re: [Done 1.3.5] includesfunctionsfunctions_email.php line 137

SMTP mail stopped working from 1.3.0 to 1.3.5. It wasn't just that line that was the problem, but I reverted all changes made to includes/functions/functions_email.php from 1.3.0 to 1.3.5 and that fixed it. Please take a look at your changes:

--- docs/1.3.0/includes/functions/functions_email.php	2006-02-27 18:11:00.000000000 -0500
+++ docs/1.3.5/includes/functions/functions_email.php	2006-09-18 18:38:30.000000000 -0400
@@ -8,7 +8,7 @@
  * @copyright Copyright 2003-2006 Zen Cart Development Team
  * @copyright Portions Copyright 2003 osCommerce
  * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
- * @version $Id: functions_email.php 3072 2006-02-27 23:11:14Z drbyte $
+ * @version $Id: functions_email.php 4137 2006-08-14 04:55:51Z drbyte $
  */
 
 /**
@@ -88,7 +88,9 @@
       for ($i=0, $n=$size; $i<$n; $i+=2) {
         $zen_fix_current = $zen_fix_currencies[$i];
         $zen_fix_replace = $zen_fix_currencies[$i+1];
-        while (strstr($email_text, $zen_fix_current)) $email_text = str_replace($zen_fix_current, $zen_fix_replace, $email_text);
+        if (strlen($zen_fix_current)>0) {
+          while (strpos($email_text, $zen_fix_current)) $email_text = str_replace($zen_fix_current, $zen_fix_replace, $email_text);
+        }
       }
 
       // fix double quotes
@@ -116,8 +118,8 @@
 
       // Build the email based on whether customer has selected HTML or TEXT, and whether we have supplied HTML or TEXT-only components
       if (!zen_not_null($email_text)) {
-        $text = str_replace('<br[[:space:]]*/?[[:space:]]*>', "@CRLF", $block['EMAIL_MESSAGE_HTML']);
-        $text = str_replace('</p>', '</p>@CRLF', $text);
+        $text = str_replace('<br[[:space:]]*/?[[:space:]]*>', "\n", $block['EMAIL_MESSAGE_HTML']);
+        $text = str_replace('</p>', "</p>\n", $text);
         $text = htmlspecialchars(stripslashes(strip_tags($text)));
       } else {
         $text = strip_tags($email_text);
@@ -131,10 +133,11 @@
       if ($debug_mode=='on') $mail->SMTPDebug = true;
       if (EMAIL_TRANSPORT=='smtp' || EMAIL_TRANSPORT=='smtpauth') {
         $mail->IsSMTP();                           // set mailer to use SMTP
-        $mail->Host = EMAIL_SMTPAUTH_MAIL_SERVER;  // specify main (could also do backup server... future feature?)
+        $mail->Host = EMAIL_SMTPAUTH_MAIL_SERVER;
+        if (EMAIL_SMTPAUTH_MAIL_PORT != '25' & EMAIL_SMTPAUTH_MAIL_PORT != '') $mail->Port = EMAIL_SMTPAUTH_MAIL_PORT;
         if (EMAIL_TRANSPORT=='smtpauth') {
           $mail->SMTPAuth = true;     // turn on SMTP authentication
-          $mail->Username = (utilGeneral::varNotNull(EMAIL_SMTPAUTH_MAILBOX)) ? EMAIL_SMTPAUTH_MAILBOX : EMAIL_FROM;  // SMTP username
+          $mail->Username = (zen_not_null(EMAIL_SMTPAUTH_MAILBOX)) ? EMAIL_SMTPAUTH_MAILBOX : EMAIL_FROM;  // SMTP username
           $mail->Password = EMAIL_SMTPAUTH_PASSWORD; // SMTP password
         }
       }
@@ -144,6 +147,9 @@
       $mail->AddAddress($to_email_address, $to_name);
       //    $mail->AddAddress($to_email_address);    // (alternate format if no name, since name is optional)
 
+      // set proper line-endings based on switch ... important for windows vs linux hosts:
+      $mail->LE = (EMAIL_LINEFEED == 'CRLF') ? "\r\n" : "\n";
+
       $mail->WordWrap = 76;    // set word wrap to 76 characters
 
       // set the reply-to address.  If none set yet, then use Store's default email name/address.
@@ -155,6 +161,10 @@
       // 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;
+      }
+
       // process attachments
       $zco_notifier->notify('NOTIFY_EMAIL_BEFORE_PROCESS_ATTACHMENTS');
       // Note: $attachments_list array requires that the 'file' portion contains the full path to the file to be attached
@@ -179,6 +189,10 @@
         $mail->Body    = $text;        // text-only content of message
       }
 
+/**
+ * Send the email. If an error occurs, trap it and display it in the messageStack
+ */
+// EMAIL_FRIENDLY_ERRORS ... debating whether to reinstate it to suppress the messageStack in this case too, or not. 
       $zco_notifier->notify('NOTIFY_EMAIL_READY_TO_SEND');
       if (!$mail->Send()) {
         $messageStack->add('header',sprintf(EMAIL_SEND_FAILED . ' '. $mail->ErrorInfo, $to_name, $to_email_address, $email_subject),'error');
@@ -299,10 +313,11 @@
     fclose($fh);
 
     //strip linebreaks and tabs out of the template
-//    $file_holder = zen_convert_linefeeds(array("\r\n", "\n", "\r", "\t"), '', $file_holder);
-    $file_holder = zen_convert_linefeeds(array("\t"), ' ', $file_holder);
+//  $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 ($block['EMAIL_STORE_NAME']=='')       $block['EMAIL_STORE_NAME']       = STORE_NAME;
     if ($block['EMAIL_STORE_URL']=='')        $block['EMAIL_STORE_URL']        = '<a href="'.HTTP_CATALOG_SERVER . DIR_WS_CATALOG.'">'.STORE_NAME.'</a>';
@@ -314,7 +329,7 @@
     if ($block['EMAIL_DATE_SHORT']=='')       $block['EMAIL_DATE_SHORT']       = zen_date_short(date("Y-m-d"));
     if ($block['EMAIL_DATE_LONG']=='')        $block['EMAIL_DATE_LONG']        = zen_date_long(date("Y-m-d"));
     if ($block['CHARSET']=='')                $block['CHARSET']                = CHARSET;
-    //  if ($block['EMAIL_STYLESHEET']=='')       $block['EMAIL_STYLESHEET']       = str_replace(array("\r\n", "\n", "\r"), '',file_get_contents(DIR_FS_EMAIL_TEMPLATES.'stylesheet.css'));
+    //  if ($block['EMAIL_STYLESHEET']=='')       $block['EMAIL_STYLESHEET']       = str_replace(array("\r\n", "\n", "\r"), "",@file_get_contents(DIR_FS_EMAIL_TEMPLATES.'stylesheet.css'));
 
     if ($block['EXTRA_INFO'] =='EXTRA_INFO')  $block['EXTRA_INFO']  = '';
     if (substr($module,-6) != '_extra' && $module != 'contact_us')  $block['EXTRA_INFO']  = '';
28 Sep 2006, 9:26 PM
#3
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: [Done 1.3.5] includesfunctionsfunctions_email.php line 137

You're correct -- that is a bug.

skelly:

    if (EMAIL_SMTPAUTH_MAIL_PORT != '25' && EMAIL_SMTPAUTH_MAIL_PORT != '') $mail->Port = EMAIL_SMTPAUTH_MAIL_PORT;

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.