$message.="<img src='cf_logo.png'/>";
上面的代码没有在php中显示图像 我需要将图像显示为信息的正文。没有附件。
答案 0 :(得分:0)
尝试以下代码:
$mail = new PHPMailer();
$mail->isSMTP(); // send via SMTP
//Enable SMTP debugging
// 0 = off (for production use)
// 1 = client messages
// 2 = client and server messages
//$mail->SMTPDebug = 2;
$mail->Host = $host; //SMTP server
$mail->Port = $port; //set the SMTP port; 587 for TLS
$mail->SMTPSecure = 'tls'; // secure transfer enabled REQUIRED for Gmail
if (strlen($username)) {
$mail->SMTPAuth = true;
$mail->Username = $username;
$mail->Password = $password;
} else {
$mail->SMTPAuth = false;
}
$mail->From = $from; // FROM EMAIL
$mail->FromName = $fromName; // FROM NAME
$mail->addAddress($to);
$mail->addReplyTo($from);
$mail->IsHTML($html);
$mail->Subject = $subject; // YOUR SUBJECT
$mail->Body = $message; // YOUR BODY
$mail->addAttachment($attachment); // YOUR ATTACHMENT FILE PATH
if ($mail->send()) {
echo "Message Sent";exit;
} else {
echo "Message Not Sent<br>";
echo "Mailer Error: " . $mail->ErrorInfo;exit;
}
注意:您需要包含php邮件程序类。
答案 1 :(得分:0)
您需要完整的路径:
<img src='add your domain here'/cf_logo.png>
答案 2 :(得分:0)
尝试一下,它可能会起作用。,像这样,在图片网址的前面使用http://