Adr*_*zza 3 php outlook html-email
我有几个简单的表单发送一个HTML专用的电子邮件.大多数客户端(Gmail,Lotus Notes 8,hotmail/live,windows live mail,outlook express)都可以收到电子邮件,但Outlook 2007却没有.
代码如下所示:
$data="
<html>
<body>
<strong><u>$sub</u></strong><br><br>
<strong>Name:</strong> {$_POST["nombre"]}<br><br>
<strong>Phone:</strong>{$_POST["telefono"]}<br><br>
<strong>Email:</strong> {$_POST["email"]}<br><br>
<strong>Subject:</strong> {$_POST["asunto"]}<br><br>
<strong>Question:</strong> {$_POST["consulta"]}</strong>
</body>
</html>";
$header = "Reply-To: $from\r\n";
$header .= "From: \"".$_POST["nombre"]."\" <$from>\r\n";
$header .= "MIME-Version: 1.0\r\n";
$header .= "Content-Type: text/html; charset=iso-8859-1\r\n";
$enviado = mail($destino,$sub,$data,$header);
Run Code Online (Sandbox Code Playgroud)
($from是验证消息的唯一部分)
客户收到的消息如下所示:
Content-Type: text/html; charset=iso-8859-1
From: Consulta de "Boss" <boss@myfirm.com>
Reply-To: boss@myfirm.com
X-Mailer: PHP/
<strong><u>Solicitud de envío de recetas -
CLIENT</u></strong><br><br><strong>Nombre y Apellido:</strong>
Boss<br><br><strong>Email:</strong>
boss@myfirm.com<br><br><br>
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
您是否尝试过发送多部分电子邮件,在执行此操作时我们从未遇到过outlook 2k3和2k7的问题(除了糟糕的HTML呈现)
<?php
$header = "From: Sender <sen...@domain.org>\r\n";
$header .= "Reply-to: Sender <blabla...@domain.net>\r\n";
$header .= "X-Mailer: Our Php\r\n";
$boundary = "==String_Boundary_x" .md5(time()). "x\r\n";
$boundary2 = "==String_Boundary2_y" .md5(time()). "y\r\n";
$header .= "MIME-Version: 1.0\r\n";
$header .= "Content-Type: multipart/related;\r\n";
$header .= " type="multipart/alternative";\r\n";
$header .= " boundary="$boundary";\r\n";
$message = "If you read this, your email client doesn't support MIME\r\n";
$message .= "--$boundary\r\n";
$message .= "Content-Type: multipart/alternative;\r\n";
$message .= " boundary="$boundary2";\r\n";
$message .= "--$boundary2\r\n";
$message .= "Content-Type: text/plain; charset=\"iso-8859-1\"\r\n";
$message .= "Content-Transfer-Encoding: 7bit\r\n";
$message .= "Alternative message in plain text format.\r\n";
$message .= "--$boundary2\r\n";
$message .= "Content-Type: text/html; charset=\"iso-8859-1\"\r\n";
$message .= "Content-Transfer-Encoding: 7bit\r\n";
$message .= "<html><body><p>HTML formatted message</p></body></html>";
Run Code Online (Sandbox Code Playgroud)
您可以用您想要的任何东西替换边界,但它们必须是唯一的.
为了在php中发送更强大和灵活的电子邮件,我建议使用SwiftMailer
编辑:因为Outlook 2007有一个非常愚蠢的HTML渲染器,你也可以尝试修复你的标记,</font>在你的例子中有一个永远不会打开,如果它是真正的邮件或有问题的拼写错误.