我需要从PHP生成的电子邮件正文中删除


I need to eliminate the from within the body of a PHP generated e-mail

这是我当前的脚本:

     $toemail = "$appemail";
            $subject = "Bursary Application";
            $headers = "MIME-Version: 1.0'r'n"
                ."From: Tem <tem@here.ca>'r'n"
                ."Content-type: text/html; charset=ISO-8859-1'r'n";
            $body =     "<h3>Thank You ".$appfirstname." for applying for the Bursary.</h3>"
                ."<hr />"
                ."<h2>Bursary Application Form</h2>"
                ."<hr />"
                ."<h4>Application Date: ".$appdate."</h4>"
                ."<h4>First Name: ".$appfirstname."</h4>"
                ."<h4>Last Name: ".$applastname."</h4>"
                ."<h4>Birthdate: ".$birthdate."</h4>"
                ."<h4>Mailing Address: ".$appmailingaddress."</h4>"
                ."<h4>City: ".$appcity."</h4>"
                ."<h4>Province: ".$appprovstate."</h4>"
                ."<h4>Postal Code: ".$apppc."</h4>"
                ."<h4>Phone Number: ".$appphone."</h4>"
                ."<h4>Graduation Date: ".$graddate."</h4>"
                ."<h4>Email Address: ".$appemail."</h4>"
                ."<h4>Post Secondary Plans: ".$psplans."</h4>"
                ."<h4>Musical Accomplishments: ".$ma."</h4>"
                ."<h4>Hobbies: ".$hobbies."</h4>"
                ."<h4>Why I enjoy music: ".$why."</h4>"
                ."<h4>How I will use the monetary award: ".$how."</h4>"
                ."<h4>What I would say to the donor: ".$saydonor."</h4>"
                ."<br>"
                ."<br>"
                ."<hr />"
                ."<h4>Thank you for your application.</h4>"
                ."<br>"
                ."<br>"
                ;
            mail($toemail, $subject, $body, $headers);

我从表格中获取数据,并使用文本字段作为段落答案。我以测试数据$psplans的形式发送此信息。每个号码后面都有回车:

1) 第1行2) 第2行3) 3号线

我在电子邮件的正文中得到了这个:

二次规划后:1)1号线''r''n2)2号线''r''n3)3号线

我找不到消除这个问题的方法。非常感谢您的帮助

您在电子邮件中输出的是html,而不是文本。html源代码中的换行符不会在输出中显示为换行符。

您可以简单地使用php函数nl2br:http://php.net/manual/en/function.nl2br.php

更改线路

            ."<h4>Post Secondary Plans: ".$psplans."</h4>"

            ."<h4>Post Secondary Plans: ".nl2br($psplans)."</h4>"

或者自己使用<br>标记,而不是已经插入的'n'r序列。

尝试用html br标签替换这些字符:

$psplans = preg_replace("/'r'n|'r|'n/",'<br/>',$psplans);

然后用作

    ."<h4>Post Secondary Plans: ".$psplans."</h4>"