我的phpmailer工作正常,但徽标不会显示在yahoomail上,但它会显示在网络邮件上。什么可能是错的?
我尽可能地完成了。
感谢。
require 'PHPMailerAutoload.php';
$mail = new PHPMailer;
//$mail->SMTPDebug = 3; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'mail.example.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'username'; // SMTP username
$mail->Password = 'password'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
$mail->From = 'email@example.com';
$mail->FromName = 'John Doe';
$mail->addAddress('email@eaxample.com', 'John Doe'); // Add a recipient
$mail->addAddress('email@eaxample.com.com'); // Name is optional
$mail->addReplyTo('email@eaxample.com.com', 'John Doe');
//$mail->addCC('cc@example.com');
//$mail->addBCC('bcc@example.com');
//$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
$mail->addAttachment('logo.png', 'logoimage');
//$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'THINKING ALOUD';
$mail->Body = '
<img src="cid:logoimage">
<h2>Welcome</h2>
Hello. It me <b>Everyone!</b>';
$mail->AltBody = 'Hello, its me Everyone';
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
答案 0 :(得分:0)
感谢。 我发现了问题发生的原因。问题是$ mail-&gt; addAttachment('logo.png','logoimage')。我改为$ mail-&gt; embedImage('logo.png','logoimage','logo.png')瞧!它奏效了。
所以addAttachment只被识别为附件,但是webmail仍然会读取它,但雅虎不会
答案 1 :(得分:0)
您正在寻找另一种方法。相反:
$ mail-&gt; addAttachment(&#39; logo.png&#39;,&#39; logoimage&#39;);
使用以下代码将图像嵌入到邮件中:
$ mail-&gt; AddEmbeddedImage(&#39; logo.png&#39;,&#39; logoimage&#39;);