Skip to content

Instantly share code, notes, and snippets.

@mauriciogofas
Created February 5, 2015 15:55
Show Gist options
  • Save mauriciogofas/6a00b76d8563b23940b4 to your computer and use it in GitHub Desktop.
Save mauriciogofas/6a00b76d8563b23940b4 to your computer and use it in GitHub Desktop.
Testing your WordPress email settings for the wp_mail function
<?php
/**
* Credit: http://www.butlerblog.com/2012/09/23/testing-the-wp_mail-function/
* Update variable settings.
* Load to your WP root folder.
*/
// Set $to as the email you want to send the test to
$to = "email@domain.com";
// No need to make changes below this line
// Email subject and body text
$subject = 'wp_mail function test';
$message = 'This is a test of the wp_mail function: wp_mail is working';
$headers = '';
// Load WP components, no themes
define('WP_USE_THEMES', false);
require('wp-load.php');
// Call the wp_mail function, display message based on the result.
if( wp_mail( $to, $subject, $message, $headers ) ) {
// the message was sent...
echo 'The test message was sent. Check your email inbox.';
} else {
// the message was not sent...
echo 'The message was not sent!';
};
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment