diff options
author | Dries Buytaert <dries@buytaert.net> | 2003-09-29 18:35:46 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2003-09-29 18:35:46 +0000 |
commit | 7531e82969cda841d2e03a736c2b0568ed2647e7 (patch) | |
tree | 3308dfdbacd4da3dedf6e802b67591887fd75b63 /modules/user/user.module | |
parent | d80140b442fd233c80ca79e128a41c5874b77bee (diff) | |
download | brdo-7531e82969cda841d2e03a736c2b0568ed2647e7.tar.gz brdo-7531e82969cda841d2e03a736c2b0568ed2647e7.tar.bz2 |
- Made sure non US-ASCII mails are sent out properly. Patch by Gabor.
TODO: rename user_mail() to drupal_mail() and move it to common.inc.
Other modules, such as the project module, should use this as well
or they risk to send out /invalid/ mails.
Diffstat (limited to 'modules/user/user.module')
-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)); |