2
I am trying to send email with image embedded in the text through the Boundary.
In Gmail everything beautiful, as always, but in Outlook does not arrive the text in HTML and the image arrives as an attachment.
<?
@date_default_timezone_set('America/Bahia');
$imagem_nome="imagens/logomarca.png";
$arquivo=fopen($imagem_nome,'r');
$contents = fread($arquivo, filesize($imagem_nome));
$encoded_attach = chunk_split(base64_encode($contents));
fclose($arquivo);
$limitador = "_=======". date('YmdHms'). time() . "=======_";
$limitador2 = "_=======". date('sYmdHms'). time() . "=======_";
$mailheaders = "From: [email protected]\r\n";
$mailheaders .= "MIME-version: 1.0\r\n";
$mailheaders .= "Content-type: multipart/related; boundary=\"$limitador\"\r\n";
$cid = date('YmdHms').'.'.time();
$texto="
<html>
<body>
<img src=\"cid:$cid\">
<font size=6><br />blablabla </font>
</body>
</html>
";
$msg_body = "--$limitador\r\n";
$msg_body .= "Content-Type: multipart/alternative; boundary=\"$limitador2\"\r\n";
$msg_body .= "--$limitador2\r\n";
$msg_body .= "Content-type: text/html; charset=iso-8859-1\r\n";
$msg_body .= "Content-Transfer-Encoding: quoted-printable\r\n";
$msg_body .= "$texto";
$msg_body .= "--$limitador2--\r\n";
$msg_body .= "--$limitador\r\n";
$msg_body .= "Content-type: image/png; name=\"$imagem_nome\"\r\n";
$msg_body .= "Content-Transfer-Encoding: base64\r\n";
$msg_body .= "Content-Disposition: inline; filaname=\"$imagem_nome\"\r\n";
$msg_body .= "Content-ID: <$cid>\r\n";
$msg_body .= "\n$encoded_attach\r\n";
$msg_body .= "--$limitador--\r\n";
if(mail("[email protected]","TEste",$msg_body, $mailheaders)){
echo"Mensagem enviada";
}
?>
What can I do to solve the problem?
So when it comes to email, it is always indicated to use tables, to stay standardized on all email clients, because as even you said or outlook is the one that gives the most headache. Here is a document for you to see some tips Email Marketing Creation Pattern
– IgorCarvalho
I’m doing something similar using PHP Perl Mail, just add the image with Attach and everything works out.
– Cesar Romero