Click to See Complete Forum and Search --> : send HTML tags in mail using PHP


urs
December 11th, 2003, 03:16 AM
<?php
if (trim($comments) != "" )
{
$comments1="<html><body><p>Support request from : ". $sendername . " Email : <a href='mailto:" . $email . "?subject=Your support request at cynapse.co.in'>" . $email . "</a></p>";
$comments1.="<p>Subject: " . $subject . "</p>";
$comments1.="<p>Comments: " . $comments. "</p></body></html>";
$ret=mail("support@cynapse.co.in","Site Support Request",$comments1,"From:user@cynapse.co.in") or die("Could not send support request. Please try again later.");
}
else
{
$failure = TRUE;
}
?>

now this is how i am sending an email to the site admin.
but when he opens his mail in outlook he just gets the string and not an HTML page.
how to send html codes so that he can view it like html pages
i hope i have made my problem clear

plzz help me

professorX
December 11th, 2003, 05:50 AM
Try it:

$ret=mail("support@cynapse.co.in","Site Support Request",$comments1,"From:user@cynapse.co.in\r\n" . "Content-type: text/html; charset=iso-8859-1\r\n") or die("Could not send support request. Please try again later.");

urs
December 11th, 2003, 06:08 AM
ok got it
thanx professorX
i just added '$headers'

$headers = "From:u@me.com\n";
$headers .= "Content-Type: text/html; charset=iso-8859-1\n";

$ret=mail("support@cynapse.co.in","Site Support Request",$comments1,$headers)

professorX
December 11th, 2003, 06:24 AM
Use "\r\n" is better way.

urs
December 12th, 2003, 08:20 AM
hello
i dont php at all
i was asked to go through somebody else code rectify the errors
so i dont know what does "\r\n" means and y it is used for

professorX
December 12th, 2003, 08:45 AM
$headers = "From:u@me.com\n";
$headers .= "Content-Type: text/html; charset=iso-8859-1\n";

Better way is so:
$headers = "From:u@me.com\r\n";
$headers .= "Content-Type: text/html; charset=iso-8859-1\r\n";