diff options
Diffstat (limited to 'modules/user')
-rw-r--r-- | modules/user/user.module | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/modules/user/user.module b/modules/user/user.module index b4f80abfb..8220ad793 100644 --- a/modules/user/user.module +++ b/modules/user/user.module @@ -311,10 +311,39 @@ function user_mail($mail, $subject, $message, $header) { ** http://www.rfc-editor.org/rfc/rfc2646.txt ** */ - return mail($mail, $subject, str_replace("\r", "", $message), $header); + return mail( + $mail, + user_mail_encode($subject), + str_replace("\r", "", $message), + "MIME-version: 1.0\nContent-type: text/plain; charset=UTF-8; format=flowed\nContent-transfer-encoding: 8BIT\n" . $header + ); } } +// Original code by <gordon at kanazawa-gu dot ac dot jp> +function user_mail_encode($string) { + + // define start delimimter, end delimiter and spacer + $end = "?="; + $start = "=?UTF-8?B?"; + $spacer = "{$end}\r\n{$start}"; + + // determine length of encoded text within + // chunks and ensure length is even + $length = 75 - strlen($start) - strlen($end); + $length = floor($length/2) * 2; + + // encode the string and split it into chunks + // with spacers after each chunk + $string = base64_encode($string); + $string = chunk_split($string, $length, $spacer); + + // remove trailing spacer and add start and end delimiters + $spacer = preg_quote($spacer); + $string = preg_replace("/{$spacer}$/", "", $string); + return ($start . $string . $end); +} + function user_deny($type, $mask) { $allow = db_fetch_object(db_query("SELECT * FROM {access} WHERE status = '1' AND type = '%s' AND LOWER('%s') LIKE LOWER(mask)", $type, $mask)); |