From 7457a64443e25650728bcbe47f4649e21c04f4e6 Mon Sep 17 00:00:00 2001 From: rub Date: Sat, 17 Jun 2006 22:56:35 +0000 Subject: Issue ID 0000407: accents are not allowed in mail headers git-svn-id: http://piwigo.org/svn/trunk@1361 68402e56-0260-453c-a942-63ccdbb3a9ee --- include/functions.inc.php | 17 +++++++++++++++++ include/functions_mail.inc.php | 12 ++++++++---- 2 files changed, 25 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/functions.inc.php b/include/functions.inc.php index f8f65c031..12fe7200d 100644 --- a/include/functions.inc.php +++ b/include/functions.inc.php @@ -818,6 +818,23 @@ function l10n($key) return isset($lang[$key]) ? $lang[$key] : $key; } +/** + * Translate string in string ascii7bits + * It's possible to do that with iconv_substr but this fonction is not avaible on all the providers. + * + * @param string str + * @return string + */ +function str_translate_to_ascii7bits($str) +{ + global $lang_table_translate_ascii7bits; + + $src_table = array_keys($lang_table_translate_ascii7bits); + $dst_table = array_values($lang_table_translate_ascii7bits); + + return str_replace($src_table , $dst_table, $str); +} + /** * returns the corresponding value from $themeconf if existing. Else, the * key is returned diff --git a/include/functions_mail.inc.php b/include/functions_mail.inc.php index 86ded9473..a209c6f04 100644 --- a/include/functions_mail.inc.php +++ b/include/functions_mail.inc.php @@ -78,13 +78,15 @@ function get_mail_configuration() */ function format_email($name, $email) { + $cvt7b_name = str_translate_to_ascii7bits($name); + if (strpos($email, '<') === false) { - return $name.' <'.$email.'>'; + return $cvt7b_name.' <'.$email.'>'; } else { - return $name.$email; + return $cvt7b_name.$email; } } @@ -95,6 +97,8 @@ function pwg_mail($to, $from = '', $subject = 'PhpWebGallery', $infos = '') { global $conf, $conf_mail; + $cvt7b_subject = str_translate_to_ascii7bits($subject); + if (!isset($conf_mail)) { $conf_mail = get_mail_configuration(); @@ -126,11 +130,11 @@ function pwg_mail($to, $from = '', $subject = 'PhpWebGallery', $infos = '') { $options = '-f '.$from; - return mail($to, $subject, $content, $headers, $options); + return mail($to, $cvt7b_subject, $content, $headers, $options); } else { - return mail($to, $subject, $content, $headers); + return mail($to, $cvt7b_subject, $content, $headers); } } -- cgit v1.2.3