简体   繁体   中英

HTML email message condensed

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);

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.

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.

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.

</br> ,请使用<br /><br>代替</br> (插入HTML新行),因为它不是HTML有效标记。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM