diff options
| author | alec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2010-02-25 20:29:47 +0000 |
|---|---|---|
| committer | alec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2010-02-25 20:29:47 +0000 |
| commit | b10451f177caa6a3c9267b39f5e7e1d933ec4c06 (patch) | |
| tree | b1144f39d7549b05ac1c1cb15a3e8119c6ce086e | |
| parent | 4544525a78f8fb5fb953de0b6bd76b75533054ba (diff) | |
- improve transfer encoding choosing
git-svn-id: https://svn.roundcube.net/trunk@3292 208e9e7b-5314-0410-a742-e7e81cd9613c
| -rw-r--r-- | roundcubemail/program/steps/mail/sendmail.inc | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/roundcubemail/program/steps/mail/sendmail.inc b/roundcubemail/program/steps/mail/sendmail.inc index 7e9e89519..6691e000c 100644 --- a/roundcubemail/program/steps/mail/sendmail.inc +++ b/roundcubemail/program/steps/mail/sendmail.inc @@ -415,10 +415,6 @@ else $MAIL_MIME->setTXTBody($plugin['body'], false, true); } -// chose transfer encoding -$charset_7bit = array('ASCII', 'ISO-2022-JP', 'ISO-8859-1', 'ISO-8859-2', 'ISO-8859-15'); -$transfer_encoding = in_array(strtoupper($message_charset), $charset_7bit) ? '7bit' : '8bit'; - // add stored attachments, if any if (is_array($_SESSION['compose']['attachments'])) { @@ -446,7 +442,9 @@ if (is_array($_SESSION['compose']['attachments'])) $ctype, $attachment['name'], ($attachment['data'] ? false : true), - ($ctype == 'message/rfc822' ? $transfer_encoding : 'base64'), + // @TODO: quoted-printable for message/rfc822 is safe, + // but we should check that 7bit or 8bit is possible here + ($ctype == 'message/rfc822' ? 'quoted-printable' : 'base64'), ($ctype == 'message/rfc822' ? 'inline' : 'attachment'), $message_charset, '', '', $CONFIG['mime_param_folding'] ? 'quoted-printable' : NULL, @@ -456,6 +454,12 @@ if (is_array($_SESSION['compose']['attachments'])) } } +// choose transfer encoding for plain/text body +if (preg_match('/[^\x00-\x7F]/', $MAIL_MIME->getTXTBody())) + $transfer_encoding = '8bit'; +else + $transfer_encoding = '7bit'; + // encoding settings for mail composing $MAIL_MIME->setParam('text_encoding', $transfer_encoding); $MAIL_MIME->setParam('html_encoding', 'quoted-printable'); |
