forumnz Posted December 21, 2007 Share Posted December 21, 2007 I want to send this email in HTML format, but doesn't work. It works fine without the $HTML, but displays an error with it. Am I doing it right? <?php $cemail = $_REQUEST['email'] ; $name = $_REQUEST['name'] ; $to = $_REQUEST['memail'] ; $headers = "SUBJECT"; $message = "Hello<br />How are you? Text"; $subject = "Win with SOmeone!"; mail($HTML,$to,$subject,$message,$headers); echo "Mail Sent."; ?> Link to comment https://forums.phpfreaks.com/topic/82744-email-sending-in-html/ Share on other sites More sharing options...
p2grace Posted December 21, 2007 Share Posted December 21, 2007 Here's a script I wrote for sending html emails. // Send HTML Email // This function is used for emailing a standardized form $headers = "From: $from \r\n"; $headers .= "Cc: $cc \r\n"; $headers .="Bcc: $bcc \r\n"; $boundary = uniqid(md5(date("YmdHis"))); // Check if there is a file attachment $headers .= "Content-Type: multipart/alternative" . "; boundary = $boundary\r\n\r\n"; //message to people with clients who don't understand MIME $headers .= "This is a MIME encoded message.\r\n\r\n"; //HTML version of message $headers .= "--$boundary\r\n" . "Content-Type: text/html; charset=ISO-8859-1\r\n" . "Content-Transfer-Encoding: base64\r\n\r\n"; $headers .= chunk_split(base64_encode("$html")); $mailSucceed = @mail($to, $subject, "", $headers); if($mailSucceed){ echo "<p style=\"color: #336699; font-weight: bold;\">Mail Sent Successfully</p>"; }else{ echo "<p style=\"color: #336699; font-weight: bold;\">Mail Failed to Send</p>"; } This requires a $subject, $from, $to, $bcc, $cc, and $html variables before running. The $html would be the html of the email being sent. Link to comment https://forums.phpfreaks.com/topic/82744-email-sending-in-html/#findComment-420853 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.