Reputation: 3063
I'm using PHPMailer for the contact form on my website. It works fine but the only issue is that everything is put on the same row in the body of the message (the message, the url the message is sent from, and the user agent), despite the "\n" which should put everything on a different line. What is the issue? Thanks,
$mail->Body = $_POST['message']."\nFrom page: ". str_replace("http://", "", $_SERVER['HTTP_REFERER']) . "\n" . $_SERVER ['HTTP_USER_AGENT'];
Upvotes: 0
Views: 90
Reputation: 848
You seem to have enabled HTML email, for instance like this:
$mail->IsHTML(true);
The solution is then to replace "\n" with "<br>", like so:
$mail->Body = $_POST['message'].<br>From page: ". str_replace("http://", "", $_SERVER['HTTP_REFERER']) . "<br>" . $_SERVER ['HTTP_USER_AGENT'];
Upvotes: 1
Reputation: 11494
Windows uses \r\n
Carriage Return, Line Feed (from typewriter days) and 'nix operating systems use Line Feed \n
so it is likely you were testing in a windows environment. In any case the default output is in HTML so you would indeed want to use <br>
instead. Not sure about PHPMailer's altBody
though, maybe you can find out.
Upvotes: 0