Php 向嵌入图像添加样式

Php 向嵌入图像添加样式,php,phpmailer,Php,Phpmailer,我在电子邮件中发送嵌入的图像。我使用: $mail->AddEmbeddedImage("../public/img/swb.jpg", "swb-image"); 当我查看电子邮件的来源时,我发现以下内容: <img border=0 width=915 height=187 style='width:9.5333in;height:1.95in' id="Picture_x0020_3" src="cid:swb-image" alt="cid:swb-image">

我在电子邮件中发送嵌入的图像。我使用:

$mail->AddEmbeddedImage("../public/img/swb.jpg", "swb-image");
当我查看电子邮件的来源时,我发现以下内容:

<img border=0 width=915 height=187 style='width:9.5333in;height:1.95in' id="Picture_x0020_3" src="cid:swb-image" alt="cid:swb-image">

是的,但PHPMailer与此无关——这完全取决于你在邮件正文中的内容,它取决于电子邮件客户端应用程序的许多差异。此外,您正在混合尺寸的像素和英寸单位,并且在引用属性时不一致。试试这个:

<img border="0" width="915" height="187" style="width:915px;height:187px;border-radius: 15px;" id="Picture_x0020_3" src="cid:swb-image" alt="swb-image">

可能是图像上不支持border radius属性,在这种情况下,您可以将其包装到一个div中,然后应用它:

<div style="border-radius: 15px;">
    <img border="0" width="915" height="187" style="width:915px;height:187px;" id="Picture_x0020_3" src="cid:swb-image" alt="swb-image">
</div>


就PHPMailer而言,唯一重要的是,您在消息正文中使用的
cid
值与传递到
addEmbeddedImage
cid
参数相同,而
addEmbeddedImage

是如何创建
$mail
对象的,该对象是
addEmbeddedImage
函数mailerExpressBlueHost的一部分(数组$mailInputs){…..您显示的样式是在
AddEmbeddedImage
方法中找到的吗?您提到的函数似乎不是普遍可用的标准/普通功能。AddEmbeddedImage是php的一部分。我没有看到任何关于样式的文档它是PHPMailer的一部分而不是php本身,但我没有看到在PHPMailer中进行任何样式设置听起来可能是您的邮件客户端正在进行样式设置。
<div style="border-radius: 15px;">
    <img border="0" width="915" height="187" style="width:915px;height:187px;" id="Picture_x0020_3" src="cid:swb-image" alt="swb-image">
</div>