diff options
author | Aleksander Machniak <alec@alec.pl> | 2013-11-25 15:53:45 +0100 |
---|---|---|
committer | Aleksander Machniak <alec@alec.pl> | 2013-11-25 15:53:45 +0100 |
commit | ac3cddac97afb04a079b3f32d689304bb5228ee2 (patch) | |
tree | b8a44bbf14e8cbd711127f9af2a6a97145fe3b91 /program/steps/mail | |
parent | acc900cb633712deabf66afe26544f7c34c145b2 (diff) |
Skip charset (or use US_ASCII) intead of UTF-8 if body contains only ASCII characters
Diffstat (limited to 'program/steps/mail')
-rw-r--r-- | program/steps/mail/sendmail.inc | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/program/steps/mail/sendmail.inc b/program/steps/mail/sendmail.inc index ea5eaaed1..fe966a4d4 100644 --- a/program/steps/mail/sendmail.inc +++ b/program/steps/mail/sendmail.inc @@ -669,10 +669,22 @@ if (is_array($COMPOSE['attachments'])) { } // choose transfer encoding for plain/text body -if (preg_match('/[^\x00-\x7F]/', $MAIL_MIME->getTXTBody())) +if (preg_match('/[^\x00-\x7F]/', $MAIL_MIME->getTXTBody())) { + $text_charset = $message_charset; $transfer_encoding = $RCMAIL->config->get('force_7bit') ? 'quoted-printable' : '8bit'; -else +} +else { + $text_charset = ''; $transfer_encoding = '7bit'; +} + +if ($flowed) { + if (!$text_charset) { + $text_charset = 'US-ASCII'; + } + + $text_charset .= ";\r\n format=flowed"; +} // encoding settings for mail composing $MAIL_MIME->setParam('text_encoding', $transfer_encoding); @@ -680,7 +692,7 @@ $MAIL_MIME->setParam('html_encoding', 'quoted-printable'); $MAIL_MIME->setParam('head_encoding', 'quoted-printable'); $MAIL_MIME->setParam('head_charset', $message_charset); $MAIL_MIME->setParam('html_charset', $message_charset); -$MAIL_MIME->setParam('text_charset', $message_charset . ($flowed ? ";\r\n format=flowed" : '')); +$MAIL_MIME->setParam('text_charset', $text_charset); // encoding subject header with mb_encode provides better results with asian characters if (function_exists('mb_encode_mimeheader')) { |