Skip to content

Instantly share code, notes, and snippets.

@chrisjangl
Created June 14, 2021 12:24
Show Gist options
  • Save chrisjangl/0aebe7232e7f375afdba760e3bc77aab to your computer and use it in GitHub Desktop.
Save chrisjangl/0aebe7232e7f375afdba760e3bc77aab to your computer and use it in GitHub Desktop.
Test whether PHP mail is working on a server
<!DOCTYPE html>
<html>
<head>
<title>Test mail services</title>
</head>
<body>
<h1>Test out the mail functionality on a server</h1>
<?php
$timestamp = "today";
// $timestamp = new DateTime('Y-m-d H:i:s');
// $timestamp = $date->format('Y-m-d H:i:s');
$to_address = "<your@email.here>";
$from_address = "";
$subject = "This is a test email";
$message = "This test email was send to <b>$to_address</b>, spoofed from <b>$from_address</b>, at $timestamp";
if ( mail( $to_address, $subject, $message ) ) {
echo "<h2>Success!</h2>";
echo "<p>Looks like we were able to send an email to <b>$to_address</b>, at <i>$timestamp</i>.</p>";
} else {
echo "<h2>No dice, man...</h2>";
echo "<p>That doesn't look like it worked.</p>";
}
?>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment