简体   繁体   中英

php mail() function strips off the return breaks

this is a sample email:

Hello $name

thank you for joining $sitenamee

regards, the management.

its saved from a textarea using a simple submit button the issue I am having is when I email it using the php mail() function I get this to my email :

Hello $name
thank you for joining $sitenamee
regards, the management.

same content which is good, but the return breaks are gone.Now IF I add <br> tags to the <textarea> and save, it sends the email with breaks. what would be the best way to resolve this without having to add <br> tags to my emails?

Use the nl2br() command to have php add the
tags at runtime as you send.

http://php.net/manual/en/function.nl2br.php

nl2br($message);
mail($to, $subject, $message);

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM