为嵌入图像添加样式
add style to embedded 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">
有没有办法添加:style="border-radius: 15px;
如果无法为嵌入图像添加样式,是否可以在 php 中圆化图像的角?
我的电子邮件功能如下所示:
function mailerExpressBlueHost(array $mailInputs){
require_once '../includes/phpmailer/PHPMailerAutoload.php';
$mail = new PHPMailer();
$mail->IsMail();
$mail->SetFrom('skipper@sailwbob.com');
$mail->IsHTML(true);
$mail->addAddress($mailInputs['addAddress']);
$mail->AddEmbeddedImage("../public/img/swb.jpg", "swb-image");
$body = $mailInputs['body'] ;
$mail->isHTML(true);
$mail->Subject = $mailInputs['subject'] ;
$mail->Body = $body;
if(!$mail->send()) {
return 'Message could not be sent.' . 'Mailer Error: ' . $mail->ErrorInfo;
} else {
return 'Message has been sent';
}
$mail->ClearAddresses();
}
是的,但 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">
可能是图像不支持边框半径 属性,在这种情况下,您可以通过将其包装在应用它的 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
参数相同.
我在电子邮件中发送嵌入图像。我使用:
$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">
有没有办法添加:style="border-radius: 15px;
如果无法为嵌入图像添加样式,是否可以在 php 中圆化图像的角?
我的电子邮件功能如下所示:
function mailerExpressBlueHost(array $mailInputs){
require_once '../includes/phpmailer/PHPMailerAutoload.php';
$mail = new PHPMailer();
$mail->IsMail();
$mail->SetFrom('skipper@sailwbob.com');
$mail->IsHTML(true);
$mail->addAddress($mailInputs['addAddress']);
$mail->AddEmbeddedImage("../public/img/swb.jpg", "swb-image");
$body = $mailInputs['body'] ;
$mail->isHTML(true);
$mail->Subject = $mailInputs['subject'] ;
$mail->Body = $body;
if(!$mail->send()) {
return 'Message could not be sent.' . 'Mailer Error: ' . $mail->ErrorInfo;
} else {
return 'Message has been sent';
}
$mail->ClearAddresses();
}
是的,但 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">
可能是图像不支持边框半径 属性,在这种情况下,您可以通过将其包装在应用它的 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
参数相同.