Last active
October 19, 2016 06:07
-
-
Save ocmca/5261cefe76b87d825318253e498b7a46 to your computer and use it in GitHub Desktop.
PHP function for sending HTML emails
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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