0
$headers  = "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=UTF-8\r\n";
$headers .= "From: <no-reply@siteemail.net>\r\n";

$to = "myemail@gmail.com";
$subject = $_POST['subject'];
$body = $_POST['body'];

mail($to, $subject, $body, $headers);

This was my body for what I put in the input: " Testing 2

Heyo

Money

#

Cya, Tony"

But when it sent the email it put this: "Testing 2\r\n\r\nHeyo\r\n\r\nMoney\r\n\r\n#\r\nCya,\r\nTony"

I don't know how to fix the issue, so I've come here for help.

UnderMyWheel
  • 241
  • 2
  • 11

1 Answers1

1

If you use content-type: text/html you have to pass to the mail function html and not plain text.

Try to use <br> instead of new lines

If you want to use \n you should use content-type: text/plain

If you want to use content-type: text/html and use plain text you can pass it to a nl2br() function

similar question here

Community
  • 1
  • 1
AndreaG
  • 239
  • 1
  • 5