Brad Bansner
asked on
PHP mail script not sending in HTML format
I have a PHP script that receives some incoming POST data to build a message. The message is sending, but not in HTML format. I receive the HTML code as text in the message, rather than an HTML-encoded mail message. I got most of this code from php.net, is there something I'm not doing quite right?
Thank you!
<?php
$recipient=$_POST['recipient'];
$subject=$_POST['subject'];
$msg='<html><head><title>Liever, Hyman & Potter</head></html><body>' . $_POST['msg'] . '</body></html>';
$headers='MIME-Version: 1.0' . '\r\n' . 'Content-type: text/html; charset=iso-8859-1' . '\r\n' . 'From:' . $_POST['sender'];
mail($recipient, $subject, $msg, $sender);
echo 'Mail Sent.';
?>
Thank you!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
First, you not sending the 'headers'. On http://us3.php.net/manual/en/function.mail.php , it shows the proper format to be: mail($to, $subject, $message, $headers);
Second, your message format is not correct or complete for 'proper' HTML Multipart email.
@marqusG's suggestion to use PHPMailer is a good idea though the current page for it is http://code.google.com/a/apache-extras.org/p/phpmailer/downloads/list
Second, your message format is not correct or complete for 'proper' HTML Multipart email.
@marqusG's suggestion to use PHPMailer is a good idea though the current page for it is http://code.google.com/a/apache-extras.org/p/phpmailer/downloads/list
ASKER