summaryrefslogtreecommitdiff
path: root/inc/mail.php
diff options
context:
space:
mode:
authorAndreas Gohr <gohr@cosmocode.de>2011-02-10 14:16:44 +0100
committerAndreas Gohr <gohr@cosmocode.de>2011-02-10 14:16:44 +0100
commit7e8e923f9382c30776c2983fc4ae90eeadf0eb64 (patch)
tree3149db83fc64ba5acfb98ae04cb5496f9a9bc0d7 /inc/mail.php
parent3ec19a6ad26bf02a10a848e2257c9d5a44e6f5e9 (diff)
downloadrpg-7e8e923f9382c30776c2983fc4ae90eeadf0eb64.tar.gz
rpg-7e8e923f9382c30776c2983fc4ae90eeadf0eb64.tar.bz2
Use Base64 encoding for long subjects FS#2169
Quoted-Printable specifies a maximum line length and some mail tools (Apple mail and Thunderbird) take this quite serious and will fail to decode subjects encoded with quoted-printable when the subject exceeds the length limit. The correct fix would be to wrap the header into multiple lines. But this seems not to be possible with mails() $subject variable. This patch switches to Base64 encoding for long subjects. A general decision if switching completely to Base64 is the best way to go is still open. (see bugreport)
Diffstat (limited to 'inc/mail.php')
-rw-r--r--inc/mail.php11
1 files changed, 9 insertions, 2 deletions
diff --git a/inc/mail.php b/inc/mail.php
index c45a7c57e..f991909d0 100644
--- a/inc/mail.php
+++ b/inc/mail.php
@@ -112,9 +112,16 @@ function _mail_send_action($data) {
}
if(!utf8_isASCII($subject)) {
- $subject = '=?UTF-8?Q?'.mail_quotedprintable_encode($subject,0).'?=';
+ $enc_subj = '=?UTF-8?Q?'.mail_quotedprintable_encode($subject,0).'?=';
// Spaces must be encoded according to rfc2047. Use the "_" shorthand
- $subject = preg_replace('/ /', '_', $subject);
+ $enc_sub = preg_replace('/ /', '_', $enc_sub);
+
+ // quoted printable has length restriction, use base64 if needed
+ if(strlen($subject) > 74){
+ $enc_subj = '=?UTF-8?B?'.base64_encode($subject).'?=';
+ }
+
+ $subject = $enc_subj;
}
$header = '';