Skip to content

Commit

Permalink
Fixed issue #6498: E-mails incorrectly encoded
Browse files Browse the repository at this point in the history
  • Loading branch information
c-schmitz committed Aug 22, 2012
1 parent 5b83d04 commit 792f2b7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion application/config/email.php
Expand Up @@ -46,6 +46,6 @@

$config['maxemails'] = 50; // The maximum number of emails to send in one go (this is to prevent your mail server or script from timeouting when sending mass mail)

$config['charset'] = "utf-8";
$config['emailcharset'] = "utf-8";

return $config; // You can change this to change the charset of outgoing emails to some other encoding - like 'iso-8859-1'
11 changes: 9 additions & 2 deletions application/helpers/common_helper.php
Expand Up @@ -4440,8 +4440,15 @@ function SendEmailMessage($body, $subject, $to, $from, $sitename, $ishtml=false,
$emailsmtpdebug = Yii::app()->getConfig("emailsmtpdebug");
$emailsmtpssl = Yii::app()->getConfig("emailsmtpssl");
$defaultlang = Yii::app()->getConfig("defaultlang");
$emailcharset = Yii::app()->getConfig("charset");
$emailcharset = Yii::app()->getConfig("emailcharset");

if ($emailcharset!='utf-8')
{
$body=mb_convert_encoding($body,$emailcharset,'utf-8');
$subject=mb_convert_encoding($subject,$emailcharset,'utf-8');
$sitename=mb_convert_encoding($sitename,$emailcharset,'utf-8');
}

if (!is_array($to)){
$to=array($to);
}
Expand Down Expand Up @@ -4557,7 +4564,7 @@ function SendEmailMessage($body, $subject, $to, $from, $sitename, $ishtml=false,
if ($ishtml) {
$mail->IsHTML(true);
$mail->Body = $body;
$mail->AltBody = strip_tags(breakToNewline(html_entity_decode($body,ENT_QUOTES,'UTF-8')));
$mail->AltBody = strip_tags(breakToNewline(html_entity_decode($body,ENT_QUOTES,$emailcharset)));
} else
{
$mail->IsHTML(false);
Expand Down

0 comments on commit 792f2b7

Please sign in to comment.