开发者

HTML email message condensed

开发者 https://www.devze.com 2023-01-16 13:28 出处:网络
The query below send开发者_如何学Cs 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

The query below send开发者_如何学Cs 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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消