Hub*_*icz 6 php embed phpmailer
我想在phpmailer中将图像包含到我的消息中.以下是我的代码,Mails正在发送但没有嵌入的图像,而是它们似乎被附加到电子邮件.不确定我的代码有什么问题,请帮忙吗?
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<?php
require_once('class.phpmailer.php');
require_once('class.smtp.php');
$mail = new PHPMailer();
$mail->CharSet = "UTF-8";
$mail->From = "xxxxx";
$mail->FromName = "Jan Nowak";
$mail->AddReplyTo('xxxx');
$mail->Host = "xxxxxx";
$mail->Mailer = "smtp";
$mail->SMTPAuth = true;
$mail->Username = "xxxxx";
$mail->Password = "xxxxxx";
$mail->Port = xxx; us?ugi poczty
$mail->Subject = "temat";
$mail->Body = 'tre?? maila';
$mail->IsHTML(true);
$mail->AddEmbeddedImage('images/Kartka.png', 'Kartka');
$mail->Body = "<h1>Test 1 of PHPMailer html</h1><p>This is a test</p>";
"<p>This is a test picture: <img src=\"images/Kartka.png\" /></p>";
//$mail->addAttachment ('images/Kartka.jpg');
$mail->AddAddress ("xxxxx");
if($mail->Send())
{
echo 'E-mail zosta? wys?any';
}
else
{
echo 'E-mail nie móg? zosta? wys?any';
}
?>
</html>
</head>
Run Code Online (Sandbox Code Playgroud)
添加<img>标签src='cid:Kartka'
$mail->AddEmbeddedImage('images/Kartka.png', 'Kartka');
$mail->Body = "<h1>Test 1 of PHPMailer html</h1><p>This is a test</p>";
"<p>This is a test picture: <img src=\"cid:Kartka\" /></p>";
Run Code Online (Sandbox Code Playgroud)
为什么要用这么多 您也可以这样:
<img src="cid:Kartka"/>
Run Code Online (Sandbox Code Playgroud)