新行(\r\\\<br/>)在电子邮件正文中不起作用 [英] new lines (\r\n) are not working in email body
本文介绍了新行(\r\\\<br/>)在电子邮件正文中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用PHP邮件()函数:
I am using PHP mail() function:
$to = 'AAAA <postmaster@xxx.xx>';
$subject = 'BBBB';
$message = "CCCC\r\nCCCC CCCC \r CCC \n CCC \r\n CCC \n\r CCCC";
$headers = 'From: DDD<postmaster@xxx.xx>' . "\r\n";
$headers .= "Content-type: text/html; charset=\"UTF-8\"; format=flowed \r\n";
$headers .= "Mime-Version: 1.0 \r\n";
$headers .= "Content-Transfer-Encoding: quoted-printable \r\n";
mail($to, $subject, $message, $headers);
收到此邮件时,如下所示:
When I receive this email it looks like this:
CCCC CCCC CCCC CCC CCC CCC CCCC
I会有这样的想法:
CCCC
CCCC CCCC CCC
CCC
CCC
CCCC
没有Content-type:标题,它工作正常。如何创建新行并使用我的内容类型声明?
It works fine without "Content-type:" header. How can i make new lines and use my Content-type declaration?
推荐答案
您需要使用 < br>
因为您的内容类型
是 text / html
。
You need to use a <br>
because your content-type
is text/html
.
它没有内容类型
标题,因为您的电子邮件将被解释为纯文本。如果你真的想使用 \\\
,你应该使用
content-type:text / plain
,但是你会丢失任何标记。
it works without the content-type
header because then your e-mail will be interpreted an plain text. If you really want to use \n
you should use content-type: text/plain
but then you'll lose any markup.
类似问题这里
这篇关于新行(\r\\\<br/>)在电子邮件正文中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文