Jump to content

Recommended Posts

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

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.