Skip to content

Instantly share code, notes, and snippets.

@ocmca
Last active October 19, 2016 06:07
Show Gist options
  • Save ocmca/5261cefe76b87d825318253e498b7a46 to your computer and use it in GitHub Desktop.
Save ocmca/5261cefe76b87d825318253e498b7a46 to your computer and use it in GitHub Desktop.
PHP function for sending HTML emails
function sendEmail($to,$from,$subject,$message){
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Create email headers
$headers .= 'From: '.$from."\r\n".
'Reply-To: '.$from."\r\n" .
'X-Mailer: PHP/' . phpversion();
// Compose a simple HTML email message
$msg = '<html><body>';
$msg .= $message;
$msg .= '</body></html>';
// Sending email
if(mail($to, $subject, $msg, $headers)){
return true;
} else{
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment