I am just working on a mail function and have problem with formatting it.
I want to send the mail as HTML. The newlines shall be converted to linebreaks. Currently I am using these functions
$mail_filtered = nl2br($mail_filtered);
$mail_filtered = htmlspecialchars($mail_filtered);
The umlauts are shown correctly, if I use this function, but the linebreaks are shown as <br/> tags in the mail.
The mail header looks like this:
"Content-Type: text/html", "Charset=utf-8"
What did I do wrong?
If you use
nl2brto add HTML line breaks to the “physical” line break sequences and applyhtmlspecialcharsafterwards, you’re also converting the added<br />into<br />that is then displayed as<br />:Do it the other way round, first use
htmlspecialcharsand thannl2br: