Skip to content

Instantly share code, notes, and snippets.

@insanedefaults
Forked from butlerblog/test_wp_mail.php
Last active August 29, 2015 14:23
Show Gist options
  • Select an option

  • Save insanedefaults/aeddbc3895c220a8f0a3 to your computer and use it in GitHub Desktop.

Select an option

Save insanedefaults/aeddbc3895c220a8f0a3 to your computer and use it in GitHub Desktop.
<?php
/**
* Update variable settings.
* Load to your WP root folder.
*/
// Set $to as the email you want to send the test to
$to = "you@yourdomain.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');
// send test message using wp_mail function
$send_message = wp_mail( $to, $subject, $message, $headers );
//display message based on the result.
if ( $sent_message ) {
// 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