PhP邮件功能每个变量输入的新行


PhP Mailing Function New Line per Variable Input

我是PhP的新手,最近向该PhP文档提交了一份表格(申请)。该文档将通过表单将用户的输入信息发送到我的电子邮件中。

<?php
$ToEmail = 'example@something.com'; 
$EmailSubject = 'Applicant for Something'; 
$mailheader = "From: ".$_POST['firstname'] .$_POST['middleinitial'] .$_POST['lastname']."'n";
$mailheader .= "Reply-To: ".$_POST["email1"]."'r'n"; 
$mailheader .= "Content-type: text/html; charset=iso-8859-1'r'n"; 
$MESSAGE_BODY = "Applicant's Full Name: ".$_POST['firstname']." ".$_POST['middleinitial']." ".$_POST['lastname']." 'n";
$MESSAGE_BODY .= "Email: ".$_POST['email']." 'n ";
$MESSAGE_BODY .= "Phone: ".$_POST['phone']." 'n ";
$MESSAGE_BODY .= "State: ".$_POST['state']." 'n ";
$MESSAGE_BODY .= "Gender: ".$_POST['gender']." 'n ";
mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure to Submit"); 
exit();
?>

然而,最细微的细节都困扰着我,每当我收到一封电子邮件时,它在正文中看起来有点像这样:

Applicant's Full Name: John A Smith Email:
johnsmith@example.com Phone:
555-555-5555 State: MA Gender:
Male

所有信息都在同一条线上。我花了4个多小时研究答案,尝试了各种解决方案,但仍然没有成功。我宁愿每个话题都单独一行。这可能只是我查看电子邮件的设备,这是我所确定的。

" 'n"

似乎无论如何都不起作用。我试了一遍又一遍。提前非常感谢。你至少可以告诉我,这是我用(苹果iPhone)接收电子邮件的查看设备,或者这是不可能的。至少那时我可以辞职。再次感谢!

如果您已将上下文类型设置为text/html,则使用'n(回车)将不起作用。您应该尝试使用<br />或任何其他希望添加换行符的HTML标记。