PHP邮件中的换行符无法正常工作

时间:2014-09-23 08:50:39

标签: php email

我正在使用PHP邮件发送联系表单详细信息...

$message="Contact Details\r\n";
$message.="Name: ".$_POST['name']."\r\n";
$message.="Phone: ".$_POST['phone']."\r\n";
$message.="Message: ".$_POST['message']."\r\n";

$header = "From: " . $from_name . " <" . $from_mail . ">\r\n";
$header .= "Reply-To: " . $replyto . "\r\n";
$header .= "X-Mailer: PHP/" . phpversion();
@mail($mailto, $subject, $message, $header);

但\ r \ n在收到的邮件中没有工作

//Output in mail
Contact Details\r\nName: ABCEDE\r\nPhone: 9999999999\r\nMessage: its my messageeee\r\n

如何为此添加换行符??

先谢谢你。

1 个答案:

答案 0 :(得分:-2)

试试这个:

$message  = "Contact Details<br />";
$message .= "Name: ".$_POST['name']."<br />";
$message .= "Phone: ".$_POST['phone']."<br />";
$message .= "Message: ".$_POST['message']."<br />";

$headers = 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$header  .= "From: " . $from_name . " <" . $from_mail . ">\r\n";
$header  .= "Reply-To: " . $replyto . "\r\n";
$header  .= "X-Mailer: PHP/" . phpversion();

@mail($mailto, $subject, $message, $header);