d
Amit DhamuSoftware Engineer
 

Mail in PHP

1 minute read 00000 views
$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
}

if (mail($to, $subject, $from_msg, $headers)) {
    // Mail successfully sent
} else {
    // There was an error sending the email.
}