Mail in PHP

Added by on January 12th, 2012 | Comments

« Back to Repository

$from_name = "Joe Bloggs";
$from_email = "joe.bloggs@gmail.com";
$from_msg = "Just wanted to say hi!";
$headers = "From: $from_name" . "\r\n";
$headers .= "Reply-To: $from_email" . "\r\n";
	
$subject = "Mail Test";
$to = "Amit Dhamu <me@me.com>";
	
if($from_name == "" || $from_email == "" || $from_msg == "") {
	// Fields are empty - kill the script
	exit;
}
	
if(mail($to, $subject, $from_msg, $headers)) {
	// Mail successfully sent
	exit;
} else {
	// There was an error sending the email.
	exit;
}


Comments

blog comments powered by Disqus