Here is my current script:
$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);
I am getting the data from the form and using text fields for the paragraph answers. I am sending this in the form as test data $psplans. There are carriage returns after each number:
1)Line 1 2)Line 2 3)Line 3
I am getting this in the body of the emailed message:
Post Secondary Plans: 1)Line 1\\r\\n2)Line 2\\r\\n3)Line 3
I cannot find a way to eliminate the \\r\\n. Your help would be appreciated. :)
Try replacing those characters with html br tag:
$psplans = preg_replace("/\r\n|\r|\n/",'<br/>',$psplans);
And then use as
."<h4>Post Secondary Plans: ".$psplans."</h4>"
You're outputting html in the email, not text. A newline in the source code of html does not appear as a line break in the output.
You can simply use the php function nl2br: http://php.net/manual/en/function.nl2br.php
to change the line
."<h4>Post Secondary Plans: ".$psplans."</h4>"
to
."<h4>Post Secondary Plans: ".nl2br($psplans)."</h4>"
or use the <br>
tag yourself instead of the \\n\\r
sequence where you insert it already.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.