From 7145e009e440ef4d6dcba2b4845656376c9d8ccd Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Mon, 30 Mar 2009 14:04:18 -0400
Subject: [PATCH] - Fix incorrect word wrapping in outgoing plaintext multibyte messages (#1485714) - Fix double footer in HTML message with embedded images

---
 program/steps/mail/sendmail.inc |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/program/steps/mail/sendmail.inc b/program/steps/mail/sendmail.inc
index eb81fc9..9607619 100644
--- a/program/steps/mail/sendmail.inc
+++ b/program/steps/mail/sendmail.inc
@@ -302,10 +302,10 @@
   $MAIL_MIME->setHTMLBody($message_body . ($footer ? "\r\n<pre>".$footer.'</pre>' : ''));
 
   // add a plain text version of the e-mail as an alternative part.
-  $h2t = new html2text($message_body);
-  $plainTextPart = $h2t->get_text() . ($footer ? "\r\n".$footer : '');
+  $h2t = new html2text($message_body, false, true, 0);
+  $plainTextPart = rc_wordwrap($h2t->get_text(), 75, "\r\n"). ($footer ? "\r\n".$footer : '');
   $plainTextPart = wordwrap($plainTextPart, 998, "\r\n", true);
-  if (!strlen($plainTextPart)) 
+  if (!strlen($plainTextPart))
     { 
     // empty message body breaks attachment handling in drafts 
     $plainTextPart = "\r\n"; 
@@ -317,7 +317,7 @@
   }
 else
   {
-  $message_body = wordwrap($message_body, 75, "\r\n");
+  $message_body = rc_wordwrap($message_body, 75, "\r\n");
   if ($footer)
     $message_body .= "\r\n" . $footer;
   $message_body = wordwrap($message_body, 998, "\r\n", true);
@@ -342,7 +342,7 @@
     if ($isHtml && ($match > 0))
     {
       $message_body = preg_replace($dispurl, ' src="'.$attachment['name'].'" ', $message_body);
-      $MAIL_MIME->setHTMLBody($message_body. ($footer ? "\r\n<pre>".$footer.'</pre>' : ''));
+      $MAIL_MIME->setHTMLBody($message_body);
       $MAIL_MIME->addHTMLImage($attachment['path'], $attachment['mimetype'], $attachment['name']);
     }
     else

--
Gitblit v1.9.1