Dear friends,
[PHP]
<?php
//define the receiver of the email
$to = 'sanjay.mit@gma il.com';
//define the subject of the email
$subject = 'Test HTML email';
//create a boundary string. It must be unique
//so we use the MD5 algorithm to generate a random hash
$random_hash = md5(date('r', time()));
//define the headers we want passed. Note that they are separated with \r\n
$headers = "From: webmaster@examp le.com\r\nReply-To: webmaster@examp le.com";
//add boundary string and mime type specification
$headers .= "\r\nConten t-Type: multipart/alternative; boundary=\"PHP-alt-".$random_hash. "\"";
//define the body of the message.
ob_start(); //Turn on output buffering
?><?php echo $random_hash; ?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<h2>Hello World!</h2>
<p>This is something with <b>HTML</b> formatting.</p>
</body>
<?php echo $random_hash; ?>--
<?
//copy current buffer contents into $message variable and delete current output buffer
$message = ob_get_clean();
//send the email
$mail_sent = @mail( $to, $subject, $message, $headers );
//if the message is sent successfully print "Mail sent". Otherwise print "Mail failed"
echo $mail_sent ? "Mail sent" : "Mail failed";
echo "sending a mail in html in php";
?>
[/PHP]
I would like to following output
Hello World!
This is something with HTML formatting.
but its give the following output
[HTML]
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<h2>Hello World!</h2>
<p>This is something with <b>HTML</b> formatting.</p>
</body>
[/HTML]
so anyone tell where i am doing wrong in this code ??????
thanks in advance !!
sanjay
[PHP]
<?php
//define the receiver of the email
$to = 'sanjay.mit@gma il.com';
//define the subject of the email
$subject = 'Test HTML email';
//create a boundary string. It must be unique
//so we use the MD5 algorithm to generate a random hash
$random_hash = md5(date('r', time()));
//define the headers we want passed. Note that they are separated with \r\n
$headers = "From: webmaster@examp le.com\r\nReply-To: webmaster@examp le.com";
//add boundary string and mime type specification
$headers .= "\r\nConten t-Type: multipart/alternative; boundary=\"PHP-alt-".$random_hash. "\"";
//define the body of the message.
ob_start(); //Turn on output buffering
?><?php echo $random_hash; ?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<h2>Hello World!</h2>
<p>This is something with <b>HTML</b> formatting.</p>
</body>
<?php echo $random_hash; ?>--
<?
//copy current buffer contents into $message variable and delete current output buffer
$message = ob_get_clean();
//send the email
$mail_sent = @mail( $to, $subject, $message, $headers );
//if the message is sent successfully print "Mail sent". Otherwise print "Mail failed"
echo $mail_sent ? "Mail sent" : "Mail failed";
echo "sending a mail in html in php";
?>
[/PHP]
I would like to following output
Hello World!
This is something with HTML formatting.
but its give the following output
[HTML]
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<h2>Hello World!</h2>
<p>This is something with <b>HTML</b> formatting.</p>
</body>
[/HTML]
so anyone tell where i am doing wrong in this code ??????
thanks in advance !!
sanjay
Comment