Answer the question
In order to leave comments, you need to log in
Where in Yii PHPMailer class to set headers?
Good afternoon,
Where is the encoding set in this class?
There is this snippet:
$from = '[email protected]';
$body =
"\n\n\t Фирма: ".$model->firm . '<br>'
."\n\n\t Город: ".$model->city . '<br>'
."\n\n\t Телефон: ".$model->phone .'<br>'
."\n\n\t Контактное лицо: ".$model->name .'<br>'
."\n\n\t Email: ".$model->email;
$body = "=?utf-8?B?".base64_encode($body)."?=";
$subject = "=?utf-8?B?".base64_encode('Запрос прайс-листа oт '.$model->name)."?="; // Кодируем тему (во избежание проблем с кодировкой)
// тут в цикле отправляю email на необходимые адреса
foreach(Yii::app()->params['email'] as $key => $email){
//mail($email, $subject, $body, $headers);
My::mailsend($email, $from ,$subject,$body);
}
static function mailsend($to,$from,$subject,$message){
$mail=Yii::app()->Smtpmail;
$mail->SetFrom($from, 'FirmaName');
$mail->Subject = $subject;
$mail->MsgHTML($message);
$mail->AddAddress($to, "");
if(!$mail->Send())
echo "Mailer Error: " . $mail->ErrorInfo;
}
Answer the question
In order to leave comments, you need to log in
If this is your PHPMAiler, then you don't need to base64-encode body and subject yourself.
https://github.com/PHPMailer/PHPMailer
$mail->CharSet = 'UTF-8'; // Кодировка текста
$mail->Encoding = 'base64'; // в каком виде передавать сообщение, оно само закодирует base64 по правилам.
$mail->addCustomHeader($header . ':' . $value); // Добавление своего заголовка
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question