点(。)在这里丢失在邮件html中发送PEAR Mail_Mime电子邮件 [英] dot(.)s are missing here & there in the mail html while sending PEAR Mail_Mime emails

查看:151
本文介绍了点(。)在这里丢失在邮件html中发送PEAR Mail_Mime电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用PEAR的邮件和mail_mime包和示例代码发送邮件,如下所示:

  $ sendStart = array() ; 
require_once('Mail.php');
require_once('Mail / mime.php');

$ sendStart ['mail'] =&邮件::工厂(邮件);
$ sendStart ['mime'] = new Mail_mime(\\\
);

$ sendStart ['mime'] - > setHTMLBody($ html);
$ sendStart ['headers'] ['Subject'] = $ title;
$ sendStart ['headers'] ['X-SMTPAPI'] ='{category:[MailID-XXX]}';

$ body = $ sendStart ['mime'] - > get(array(
'html_charset'=>'UTF-8',
'text_charset'=> ;'UTF-8',
'head_charset'=>'UTF-8'
));

// echo($ sendStart ['mime'] - > _htmlbody);出口;
$ sendStart ['mail'] - > send('xxx@example.com',$ sendStart ['mime'] - > headers($ sendStart ['headers']),$ body);

在通过此代码发送邮件时,我面临着一个奇怪的问题。电子邮件正文中有图像,有时图像不显示。当我调试问题时,我发现图像url中缺少。但是如果我在发送行之前打印邮件(正如我在代码中注释的那样),它将完美地打印图像。



正确的图片网址: http://www.domain.com/image.png



在邮件中: http://www.domaincom/image.png http:// www .domain.com / imagepng ...等。



部分HTML代码具有以下图像:

 < table cellpadding =0cellspacing =0border =0class =image-table image-2align = centerstyle =float:none; margin-left:auto; margin-right:auto; text-align:left;> 
< tbody>
< tr>
< td class =elementstyle =text-align:left; height:auto; overflow:hidden; -webkit-text-size-adjust:none;>
<! - [if gte mso 9]>< img alt =占位符图像src =http://www.domain.com/image.pngstyle =outline:none; text-decoration:none; display:block; clear:none; float:none; margin-left:auto; margin-right:auto; display:none; mso-hide:none; align =centerwidth =394><![endif] - ><![if!mso]><! - - >< img alt =占位符图像src =http://www.domain.com/image.pngstyle =outline:none; text-decoration:none; display:block; clear:none; float:none; width:100%; height:auto ; max-width:394px; margin-left:auto; margin-right:auto; * width:394px; -ms-interpolation-mode:bicubic;对齐= 中心 ><! - <![ENDIF] - GT;
< / td>
< / tr>
< / tbody>
< / table>

非常奇怪的是,它在Outlook中正常显示,但在其他客户端中没有显示outlook I有单独的代码(根据代码)。



有人有任何想法如何调试问题或任何关于此问题的评论。



已编辑



此问题与任何特定的标签无关(虽然我使用图像标签解释)我在几个地方体验到,如风格。



示例: line-heigth:1.5; 是原始的,它发送出去时更改为 line-heigth:15;



基本上它只是删除 here&电子邮件中的HTML。

解决方案

我很确定这是由点填充造成的;因为该点被用作电子邮件中的特殊指示符。您可以在 rfc 中阅读有关此内容的信息(强调添加) :


要允许所有用户合成文本透明传输,请使用以下步骤:




  • 在发送一行邮件文本之前,SMTP客户端会检查该行的第一个字符。如果是一段时间,则在行的开头插入一个额外的时间段。

  • 当SMTP服务器接收到一行邮件文本时,它会检查该行。如果该行由单个期间组成,则将其视为邮件指示符的结尾。 如果第一个字符是一个句点,并且行上还有其他字符,则第一个字符将被删除。


似乎您用于撰写这些电子邮件的客户端不执行第一个过程,而将邮件发送到的服务器强>实施它导致点消失。



修复将是让您的客户端实现填充。


I am sending a mail using PEAR's mail and mail_mime packages and sample code as below:

$sendStart=array();
require_once('Mail.php');
require_once('Mail/mime.php');

$sendStart['mail'] =& Mail::factory('mail');
$sendStart['mime'] = new Mail_mime("\n");

$sendStart['mime']->setHTMLBody($html);
$sendStart['headers']['Subject']=$title;
$sendStart['headers']['X-SMTPAPI']='{"category": ["MailID-XXX"]}';

$body=$sendStart['mime']->get(array(
        'html_charset'=>'UTF-8',
        'text_charset'=>'UTF-8',
        'head_charset'=>'UTF-8'
    ));

//echo ($sendStart['mime']->_htmlbody); exit;
$sendStart['mail']->send('xxx@example.com',$sendStart['mime']->headers($sendStart['headers']),$body);

I am facing a strange issue while sending the mails through this code. I have images inside the email body, sometimes the images not displaying. When I debug the issue, I found that . is missing in the image url. But if I print the mail just before the send line (as I comment out in the code) it prints with the image perfectly.

correct image url: http://www.domain.com/image.png

in the mail : http://www.domaincom/image.png or http://www.domain.com/imagepng ... etc.

part of the HTML code which has the image as below:

<table cellpadding="0" cellspacing="0" border="0" class="image-table image-2" align="center" style="float:none;margin-left:auto;margin-right:auto;text-align:left;">
    <tbody>
      <tr>
        <td class="element" style="text-align: left;height: auto;overflow: hidden;-webkit-text-size-adjust: none;">
          <!--[if gte mso 9]><img alt="Placeholder Image" src="http://www.domain.com/image.png" style="outline: none; text-decoration: none; display: block; clear: none; float: none;    margin-left: auto; margin-right: auto;display:none; mso-hide: none;" align="center" width="394"><![endif]--><![if !mso]><!-- --><img alt="Placeholder Image" src="http://www.domain.com/image.png" style="outline: none;text-decoration: none;display: block;clear: none;float: none;width: 100%;height: auto;max-width: 394px;margin-left: auto;margin-right: auto;*width: 394px;-ms-interpolation-mode: bicubic;" align="center"><!--<![endif]-->
        </td>
      </tr>
    </tbody>
</table>

And the very strange thing is it is displaying properly in outlook but not in other clients as for outlook I have separate code(as per the code).

Does anybody have any idea how to debug the issue or any comment on this issue.

Edited:

This issue is nothing to do with any specific tag (although I explain it using image tag), I experience it in several places such as in styles.

example : line-heigth:1.5; is the original and it changes to line-heigth:15; while sending out.

Basically it just remove the . here & there in the email HTML.

解决方案

I'm pretty sure this is caused by dot-stuffing; as the dot is used as a special indicator in emails. You can read about this in the rfc where it says (emphasis added):

To allow all user composed text to be transmitted transparently, the following procedures are used:

  • Before sending a line of mail text, the SMTP client checks the first character of the line. If it is a period, one additional period is inserted at the beginning of the line.
  • When a line of mail text is received by the SMTP server, it checks the line. If the line is composed of a single period, it is treated as the end of mail indicator. If the first character is a period and there are other characters on the line, the first character is deleted.

It seems the client you're using to compose these emails does not implement the first procedure, while the server it sends the mail to does implement it; leading to dots disappearing.

The fix would be to make your client implement the padding.

这篇关于点(。)在这里丢失在邮件html中发送PEAR Mail_Mime电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆