PHPMailer“CharSet”与“AltBody”和“AddEmbeddedImage”同时不兼容
在UTF-8中的发送体不工作时,我有以下代码:PHPMailer“CharSet”与“AltBody”和“AddEmbeddedImage”同时不兼容,php,email,phpmailer,Php,Email,Phpmailer,在UTF-8中的发送体不工作时,我有以下代码: <?php require '../phpmailer/PHPMailerAutoload.php'; $mail = new PHPMailer; $mail->CharSet = 'UTF-8'; $mail->setFrom('from@example.com', 'First Last'); $mail->addAddress('whoto@example.com', 'Joh
<?php
require '../phpmailer/PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->CharSet = 'UTF-8';
$mail->setFrom('from@example.com', 'First Last');
$mail->addAddress('whoto@example.com', 'John Doe');
$mail->Subject = 'PHPMailer mail() test';
$mail->AltBody = 'This is a plain-text message body';
$mail->AddEmbeddedImage('img_00/Mailing_febrero2015_02.jpg', 'fondo', 'fondo.jpg');
$mail->Body = 'árbol';
if (!$mail->send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
?>
但如果我删除AltBody或AddEmbeddedImage,它将以UTF-8正确发送。为什么会发生这种情况?我有最新的PHPMailer版本?
还有另一种正确的方法可以同时添加另一个主体和嵌入的图像吗?我无法复制它-我觉得它的编码正确。有一件事-使用没有HTML的嵌入式图像没有多大意义,我建议添加附件。如果您将HTML与嵌入的图像一起使用,你可能会发现使用msgHTML更容易。我只有在收件人是Outlook 2007时才会遇到这个问题。你需要定义“不工作”,并提供一个错误编码邮件的示例。如果我用Outlook 2007检查电子邮件,我看到:arbol如果我用webmail帐户检查,或者收件人是gmail帐户,我看到:arbol