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) --- CHANGELOG | 1 + config/main.inc.php.dist | 4 ++++ program/steps/mail/sendmail.inc | 32 ++++++++++++++++++++------------ 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 077e744ae..2b418d8c8 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ CHANGELOG RoundCube Webmail =========================== +- Add option to set separate footer for HTML messages (#1486660) - Add real SMTP error description to displayed error messages (#1485927) - Fix some IMAP errors handling when opening the message (#1485443) - Fix related parts aren't displayed when got mimetype other than image/* (#1486432) diff --git a/config/main.inc.php.dist b/config/main.inc.php.dist index 991d757a7..0f32b5788 100644 --- a/config/main.inc.php.dist +++ b/config/main.inc.php.dist @@ -225,6 +225,10 @@ $rcmail_config['include_host_config'] = false; // paths are relative to the RoundCube root folder $rcmail_config['generic_message_footer'] = ''; +// path to a text file which will be added to each sent HTML message +// paths are relative to the RoundCube root folder +$rcmail_config['generic_message_footer_html'] = ''; + // add a received header to outgoing mails containing the creators IP and hostname $rcmail_config['http_received_header'] = false; 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