[英]HTML e-mail in outlook using PHP mail() function
I am keep getting the source code in outlook 2013. I have read a lot of stackoverflow questions, tried all the recommended solutions, none of the helped tho. 我一直在Outlook 2013中获取源代码。我已经阅读了很多stackoverflow问题,尝试了所有推荐的解决方案,但都无济于事。
here is my php 这是我的PHP
$test1 = "test string";
// Retrieve the email template required
$message = file_get_contents('email-templates/template1.html');
// Replace the % with the actual information
$message = str_replace('%test1%', $test1, $message);
//echo $message;
$to = 'test@gmail.com';
$email_subject = "test";
$email_body = $message;
$headers = "From: $to\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\n";
$headers .= "Content-Transfer-Encoding: 8bit\n";
mail($to,$email_subject,$email_body,$headers);
using only \\n
instead of \\r\\n
, and took care of the order (this one was presented), but still working on gmail, phone, bot does not in Outlook. 仅使用
\\n
而不是\\r\\n
,并已完成顺序(此命令已提出),但仍可在gmail,phone和bot上使用,而在Outlook中却没有。
any more suggestions? 还有其他建议吗?
your code looks a lot like the example in the manpage http://php.net/manual/en/function.mail.php 您的代码很像手册页中的示例http://php.net/manual/en/function.mail.php
try ending your lines with \\r\\n (CR-LF) not just newlines, who knows 尝试用\\ r \\ n(CR-LF)结束行而不仅仅是换行符,谁知道
You can back up a step, copy-and-paste the example from php.net and see whether the problem is really on the Outlook side. 您可以备份一个步骤,从php.net复制并粘贴示例,然后查看问题是否确实在Outlook方面。 You can also pull up html emails from your inbox, and see what they're doing different (try to copy-and-paste send a copy of a good html email from within php)
您还可以从收件箱中提取HTML电子邮件,并查看它们在做什么(尝试从php中复制并粘贴发送好的HTML电子邮件的副本)
As to reinventing the wheel, if mail() predates PHPMailer, arguably it's the latter that did the reinventing... 至于重新发明轮子,如果mail()早于PHPMailer,则可以说是后者进行了重新发明...
the solution was 解决方案是
$headers .= "MIME-Version: 1.0\n" ;
$headers .= "Content-Type: text/html; charset=\"iso-8859-1\"\n";
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.