Last active
August 29, 2015 14:04
-
-
Save dirkluijk/ceb0e19a4ebe3ddd7b14 to your computer and use it in GitHub Desktop.
Test mail functionality
This file contains 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
<?php | |
//error_reporting(E_ALL); | |
//ini_set('display_errors', true); | |
ini_set('display_errors', false); | |
echo sprintf('Sending message...'); | |
$to = 'dirk@luijkwebcreations.nl'; | |
$from = 'dirk@luijkwebcreations.nl'; | |
$subject = 'Test email using PHP'; | |
$message = 'This is a test email message'; | |
$headers = array( | |
'From' => $from, | |
'X-Mailer' => 'PHP/' . phpversion(), | |
); | |
array_walk($headers, function(&$value, $key) { | |
$value = "$key: $value"; | |
}); | |
$headers = implode($headers, "\r\n"); | |
if (!@mail($to, $subject, $message, $headers)) { | |
$e = error_get_last(); | |
die(sprintf('Sending failed: %s', $e['message'])); | |
} | |
echo sprintf('Message sent to %s.', $to); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment