Skip to content

Instantly share code, notes, and snippets.

@itthinx
Last active September 6, 2021 10:50
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 itthinx/2425c4ebb2ca6a23ff48c0cd53e73fed to your computer and use it in GitHub Desktop.
Save itthinx/2425c4ebb2ca6a23ff48c0cd53e73fed to your computer and use it in GitHub Desktop.
// An example wp_mail() override that you can place in your site's wp-config.php.
// Read the corresponding post https://www.itthinx.com/2021/09/06/wordpress-mail-debugging/
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
function wp_mail( $to, $subject, $message, $headers = '', $attachments = array() ) {
$output = sprintf(
"\n\n" .
"---------- Caught email via wp_mail() override in wp-config.php ---------- \n\n" .
"To: %s\n\n" .
"Subject: %s\n\n" .
"Message: %s\n\n" .
"Headers: %s\n\n" .
"Attachments: %s\n\n" .
"-------------------------------------------------------------------------- \n\n" .
"\n\n",
$to,
$subject,
$message,
json_encode( $headers ),
json_encode( $attachments )
);
error_log( $output );
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment