Hi,

i use php mailler to send email but i don't know how to add <br> or <p> breaks into message that comes from other page with $_POST. I need it because message appears in email as an one long line.

$mail->Body    = $_POST['message']; //Not fine
$mail->Body    = "Hi,<br>How are you today.<br>Bye"; //This is what i want in above line

Thansk

Hi, i am not sure about phpmailer but for line breaks, you should use \n.
But if you want additional formatting in your emails, then use mime. Then you can use html tags also in the email.

I believe that 70 characters is the maximum length for plain-text email body lines ... I would use this PHP function

$body_content = wordwrap( $body_content, 70 );

Enjoy

Hi there.

If this is any help, I'm using HTML email for all my email functions and it is working perfectly. I am not sure, but as far as I know, you can write almost any email in html, simply just copy your html code and paste it in your php code where applicable, ie. the message part.

I use line breaks and html coding like this:

<?php
// Your code here
// Then your message body eg.
message->body"
Hello. This is <b>bold<b> text with a line break<br>
"?>

To include database data within your email;

message->body"
Your account balance is: ".$row['AccountBalance']."
Your account expires....

If you are trying to output html email and the form input for the message body is from a <textarea> field ... it should have one or more newline "\n" characters (line-breaks) already in the string you get with the $_POST variable.

If so, the easiest way to turn those line-breaks into <br> tags is this PHP function

$broken_output = nl2br( $raw_input );

So this ...

<?php

$raw_input = <<<ENDLINE
The quick brown foxu
jumped over the curious dog

Yeah, I misquoted that ...
but time it is a wasting.
ENDLINE;

print nl2br( $raw_input );

?>

... should procude this ...

The quick brown foxu<br />
jumped over the curious dog<br />
<br />
Yeah, I misquoted that ...<br />
but time it is a wasting.

Good luck

This question has already been answered. Start a new discussion instead.