Jump to content

[SOLVED] mail message text format


asmith

Recommended Posts

hey guys

how can i use html tags in my mail message ?

 

$to = "[email protected]";
$sub = "test";
$msg = "<b>hello<b><br />this is a test   \n mail!!<p>paragraph</p>";
$head = "From:john";

mail($to,$sub,$msg,$head);

 

the only thing works in he $msg is \n , in shows html tags.

or maybe i should ask how can i format the mail message text ?

Link to comment
https://forums.phpfreaks.com/topic/84090-solved-mail-message-text-format/
Share on other sites

Try this

<?php
// To send HTML mail, the Content-type header must be set
$headers  = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";

// Additional headers
$headers .= "To: peter <$to>\r\n";
$headers .= "From: john <[email protected]>\r\n";

$to = "[email protected]";
$sub = "test";
$msg = "<b>hello<b><br />this is a test   \n mail!!<p>paragraph</p>";

$msg= nl2br($msg); //convert /n to <br>

mail($to,$sub,$msg,$headers);
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.