rgb192
asked on
html to email
add html to email
want to add
<br>
\n
\t
will the output show <br> instead of linebreak
with different email clients
want to add
<br>
\n
\t
will the output show <br> instead of linebreak
with different email clients
<?php
$Name = "Da Duder"; //senders name
$email = "email@adress.com"; //senders e-mail adress
$recipient = "PersonWhoGetsIt@emailadress.com"; //recipient
$mail_body = "The text for the mail..."; //mail body
$subject = "Subject for reviever"; //subject
$header = "From: ". $Name . " <" . $email . ">\r\n"; //optional headerfields
mail($recipient, $subject, $mail_body, $header); //mail command :)
?>
That will show up as a return in the email, the \r\n will work for Linux or Windows
ASKER
when i add
<br>
\n
\t
to the mail body
sometimes is not a line break
is there code to allow html in mail()
<br>
\n
\t
to the mail body
sometimes is not a line break
is there code to allow html in mail()
Add some additional headers
<?php
$Name = "Da Duder"; //senders name
$email = "email@adress.com"; //senders e-mail adress
$recipient = "PersonWhoGetsIt@emailadress.com"; //recipient
$mail_body = "The text for the mail...<br><b>with html</b>"; //mail body
$subject = "Subject for reviever"; //subject
$header = "From: \"".$from_name."\" <".$from_email.">\n";
$header .= "To: \"".$to_name."\" <".$to_email.">\n";
$header .= "Return-Path: <".$from_email.">\n";
$header .= "MIME-Version: 1.0\n";
$header .= "Content-Type: text/html; charset=ISO-8859-1\n";
mail($recipient, $subject, $mail_body, $header); //mail command :)
?>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
if you add additional headers, it will include the HTML display.
$header = "From: \"".$from_name."\" <".$from_email.">\n";
$header .= "To: \"".$to_name."\" <".$to_email.">\n";
$header .= "Return-Path: <".$from_email.">\n";
$header .= "MIME-Version: 1.0\n";
$header .= "Content-Type: text/html; charset=ISO-8859-1\n";
$header = "From: \"".$from_name."\" <".$from_email.">\n";
$header .= "To: \"".$to_name."\" <".$to_email.">\n";
$header .= "Return-Path: <".$from_email.">\n";
$header .= "MIME-Version: 1.0\n";
$header .= "Content-Type: text/html; charset=ISO-8859-1\n";
That's exactly the solution I made!?
ASKER
will this allow both
<br>
and
\n
in the
$mail_body
<br>
and
\n
in the
$mail_body
If you use html headers, it will transfer as html only, so the answer is no, it will not allow both.
ASKER
thanks