From 5852c14d3ecc0a858e2bcadc7aeb0cd44c6b2e66 Mon Sep 17 00:00:00 2001 From: alecpl Date: Fri, 11 Jun 2010 13:57:02 +0000 Subject: - Add option to set separate footer for HTML messages (#1486660) --- program/steps/mail/sendmail.inc | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) (limited to 'program/steps/mail/sendmail.inc') diff --git a/program/steps/mail/sendmail.inc b/program/steps/mail/sendmail.inc index 3c32530a4..f94950e87 100644 --- a/program/steps/mail/sendmail.inc +++ b/program/steps/mail/sendmail.inc @@ -384,11 +384,20 @@ if (!$savedraft) { $message_body = preg_replace('/
/', '
', $message_body); } + // generic footer for all messages - if (!empty($CONFIG['generic_message_footer'])) { + if ($isHtml && !empty($CONFIG['generic_message_footer_html'])) { + $footer = file_get_contents(realpath($CONFIG['generic_message_footer_html'])); + $footer = rcube_charset_convert($footer, RCMAIL_CHARSET, $message_charset); + } + else if (!empty($CONFIG['generic_message_footer'])) { $footer = file_get_contents(realpath($CONFIG['generic_message_footer'])); $footer = rcube_charset_convert($footer, RCMAIL_CHARSET, $message_charset); + if ($isHtml) + $footer = '
'.$footer.'
'; } + if ($footer) + $message_body .= "\r\n" . $footer; } // set line length for body wrapping @@ -422,13 +431,13 @@ if ($isHtml) { $plugin = $RCMAIL->plugins->exec_hook('outgoing_message_body', array('body' => $message_body, 'type' => 'html', 'message' => $MAIL_MIME)); - $MAIL_MIME->setHTMLBody($plugin['body'] . ($footer ? "\r\n
".$footer.'
' : '')); + $MAIL_MIME->setHTMLBody($plugin['body']); // add a plain text version of the e-mail as an alternative part. $h2t = new html2text($plugin['body'], false, true, 0); - $plainTextPart = rc_wordwrap($h2t->get_text(), $LINE_LENGTH, "\r\n") . ($footer ? "\r\n".$footer : ''); + $plainTextPart = rc_wordwrap($h2t->get_text(), $LINE_LENGTH, "\r\n"); $plainTextPart = wordwrap($plainTextPart, 998, "\r\n", true); - if (!strlen($plainTextPart)) { + if (!$plainTextPart) { // empty message body breaks attachment handling in drafts $plainTextPart = "\r\n"; } @@ -447,25 +456,24 @@ if ($isHtml) { $message_body = rcmail_fix_emoticon_paths($MAIL_MIME); } else { - if ($footer) - $message_body .= "\r\n" . $footer; - + $plugin = $RCMAIL->plugins->exec_hook('outgoing_message_body', + array('body' => $message_body, 'type' => 'plain', 'message' => $MAIL_MIME)); + + $message_body = $plugin['body']; + // compose format=flowed content if enabled and not a reply message if (empty($_SESSION['compose']['reply_msgid']) && ($flowed = $RCMAIL->config->get('send_format_flowed', true))) $message_body = rcube_message::format_flowed($message_body, $LINE_LENGTH); else $message_body = rc_wordwrap($message_body, $LINE_LENGTH, "\r\n"); - + $message_body = wordwrap($message_body, 998, "\r\n", true); if (!strlen($message_body)) { // empty message body breaks attachment handling in drafts $message_body = "\r\n"; } - $plugin = $RCMAIL->plugins->exec_hook('outgoing_message_body', - array('body' => $message_body, 'type' => 'plain', 'message' => $MAIL_MIME)); - - $MAIL_MIME->setTXTBody($plugin['body'], false, true); + $MAIL_MIME->setTXTBody($message_body, false, true); } // add stored attachments, if any -- cgit v1.2.3