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.