I try to use PHPMailer to send registration, activation. etc mail to users:
require("class.phpmailer.php");
$mail -> charSet = "UTF-8";
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = "smtp.mydomain.org";
$mail->From = "[email protected]";
$mail->SMTPAuth = true;
$mail->Username ="username";
$mail->Password="passw";
//$mail->FromName = $header;
$mail->FromName = mb_convert_encoding($header, "UTF-8", "auto");
$mail->AddAddress($emladd);
$mail->AddAddress("[email protected]");
$mail->AddBCC('[email protected]', 'firstadd');
$mail->Subject = $sub;
$mail->Body = $message;
$mail->WordWrap = 50;
if(!$mail->Send()) {
echo 'Message was not sent.';
echo 'Mailer error: ' . $mail->ErrorInfo;
}
The $message
contains latin characters. Unfortunately all webmail (gmail, webmail.mydomain.org, emailaddress.domain.xx) is using a different coding.
How can I force to use UTF-8 coding to show my mail exactly the same on all mailboxes?
I tried to convert the mail header width mb_convert_encoding()
, but without luck.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…