Skip to content

Instantly share code, notes, and snippets.

@dirkluijk
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dirkluijk/ceb0e19a4ebe3ddd7b14 to your computer and use it in GitHub Desktop.
Save dirkluijk/ceb0e19a4ebe3ddd7b14 to your computer and use it in GitHub Desktop.
Test mail functionality
<?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