Jan*_*ana 13 php email pear mime
我使用PEAR的mail和mail_mime包发送邮件,示例代码如下:
$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);
Run Code Online (Sandbox Code Playgroud)
通过此代码发送邮件时,我遇到了一个奇怪的问题.我在电子邮件正文中有图像,有时图像不显示.当我调试问题时,我发现.图片网址中缺少这个问题.但是,如果我在发送行之前打印邮件(因为我在代码中注释掉),它会完美地打印出图像.
正确的图片网址: http://www.domain.com/image.png
在邮件中:http://www.domaincom/image.png或http://www.domain.com/imagepng......等
HTML代码的一部分,其图像如下所示:
<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>
Run Code Online (Sandbox Code Playgroud)
而奇怪的是它在outlook中正确显示但在其他客户端没有显示,因为我有单独的代码(根据代码).
有没有人知道如何调试问题或对此问题的任何评论.
编辑:
这个问题与任何特定的标签无关(虽然我用图片标签解释),我在几个地方体验它,比如样式.
示例:line-heigth:1.5;是原始的,并line-heigth:15;在发送时更改为.
基本上它只是删除.电子邮件HTML 中的这里和那里.
| 归档时间: |
|
| 查看次数: |
1324 次 |
| 最近记录: |