我正在使用WebApp,该WebApp生成一些QR码并将其通过邮件发送到客户端。

我读过这些,以便gmail正确解释邮件的CSS等。我应该以内联方式将其包含在HTML中。

这是我的代码:

// Headers
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'Content-Transfer-Encoding: base64' . "\r\n";
$headers .= 'To: ' . $qremail . "\r\n";
$headers .= 'From: Mehdi' . "\r\n";

$qr_images_url = "http://" . $_SERVER['HTTP_HOST'] . "/GPAYME-ticket/" . $PNG_WEB_DIR;

// Loop on the QR images

$html_email .= "<img src='" . $qr_images_url . $qr_image_name . "' style='min-width: 225px; width: 225px; max-width: 225px; min-height: 225px; height: 225px; max-height: 225px; margin-right: 15px; border: 2px solid #D8D4D4; margin-bottom: 15px;' />";

// END of the Loop on the QR images

mail($email, $subject, $html_email, $headers);


然后发送邮件。

因此<img />标记应类似于:

<img src="http://croisentoi.com/GPAYME-ticket/QRTemp/Qr-Ticket-60ac6339aa0c9cb6121160d55f769882.png" style="min-width:225px;width:225px;max-width:225px;min-height:225px;min-height:225px;max-height:225px;margin-right:15px;border:2px solid #d8d4d4;margin-bottom:15px">


收到邮件后,其内容中实际上有5种情况的<img />标记的Gmail解释:

1.一切正常:<img src="http://croisentoi.com/GPAYME-ticket/QRTemp/Qr-Ticket-60ac6339aa0c9cb6121160d55f769882.png" style="min-width:225px;width:225px;max-width:225px;min-height:225px;min-height:225px;max-height:225px;margin-right:15px;border:2px solid #d8d4d4;margin-bottom:15px">

2.图像源url属性被删除:<img style="min-width:225px;width:225px;max-width:225px;min-height:225px;min-height:225px;max-height:225px;margin-right:15px;border:2px solid #d8d4d4;margin-bottom:15px">

3.删除样式属性:<img src="http://croisentoi.com/GPAYME-ticket/QRTemp/Qr-Ticket-19cde597bca16405b41cb8e3d3391d77.png">

4.在这种情况下,Gmail会在源URL属性+中添加一个额外的字符(/ G + PAYME代替/ GPAYME):<img src="http://croisentoi.com/G+PAYME-ticket/QRTemp/Qr-Ticket-368940b3754eb9c2b0fd57285efc9535.png" style="min-width:225px;width:225px;max-width:225px;min-height:225px;min-height:225px;max-height:225px;margin-right:15px;border:2px solid #d8d4d4;margin-bottom:15px">

5.在这种情况下,Gmail会在style属性内的CSS中添加一个额外的空间(宽度:2 25像素;而不是宽度:225像素;):<img src="http://croisentoi.com/GPAYME-ticket/QRTemp/Qr-Ticket-368940b3754eb9c2b0fd57285efc9535.png" style="min-width:225px;width:2 25px;max-width:225px;min-height:225px;min-height:225px;max-height:225px;margin-right:15px;border:2px solid #d8d4d4;margin-bottom:15px">

ps:出于澄清的目的,我删除了<img src=中gmail添加的多余网址

您对此有任何想法吗?谢谢。

最佳答案

似乎您在发送电子邮件时没有考虑(base64编码?)最大行宽。这样,某些空格被插入到某处,或者部分丢失。

在这种情况下,您可以解释所有示例:


不拆分,全部一行
src属性名称中的空格(即“ s rc”)
style属性名称中的空格(即“ st lye”)
src属性值中的空格(URL编码的空格为+)
style属性值中的空格

09-07 11:31