tags:

views:

31

answers:

4

Hello,

The query below sends out an email. It works okay, but the message is condensed into basically one long paragraph. I would like a break where I have the </br> tags below. However, the </br> tags are being ignored. Any idea how I could put breaks there?

Thanks in advance,

John

        $message1 = "
    Someone made the following comment on your submission $submission:

    </br>

    $comment

    Please click the link below to see the comment in context.

    </br>

    $link1

    ";

$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

    $queryem = mail($mailaddress, "Someone has commented on your submission 
                            $submission.", $message1, $headers);
+1  A: 

The br tags introduce a line break, not a new paragraph.

If you want paragraphs, use p:

$message1 = "
<p>Someone made the following comment on your submission $submission:</p>
<p>$comment</p>
<p>Please click the link below to see the comment in context.</p>";

I assume you have sanitized $comment. If you haven't, the user can almost completely control how the e-mail will look like.

Artefacto
A: 

br tags are written <br/>, not </br>. The first is an empty tag which signifies a line break. The second implies a closing tag for opening <br> which is unnecessary.

Michael Mior
No, its `<br>`. It is HTML not XHTML.
David Dorward
Oh, and this just fixes the syntax error, it doesn't solve the problem.
David Dorward
In that case, there's a missing opening `<br>`. But `<br/>` is not just for XHTML. It's not JUST a syntax error. A closing tag does nothing on it's own.
Michael Mior
A: 

Use <br /> or <br> instead </br> for this purpose(inserting HTML new line), because isn't HTML valid tag.

Centurion
Duplicate of Michael Moir's answer, and this fixes the syntax error without touching on the actual problem.
David Dorward
@David Dorward, I edited the question.
Centurion
Not just a syntax error.
Michael Mior
A: 

Don't build MIME emails manually. As you can see, it's problematic and easy to break. Use someting like PHPMailer or Swiftmailer to do it for you. All you have to do is provide the content and addressing, and they'll take care of the headers/setup for you.

Marc B