Created
September 4, 2013 18:52
-
-
Save jeremyfelt/6441206 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: Log wp_mail() | |
Version: 0.1 | |
Plugin URI: http://wsu.edu | |
Description: Log emails sent through WordPress to a text file. | |
Author: jeremyfelt, wsu.edu | |
*/ | |
add_filter( 'wp_mail', 'wsu_log_wp_mail', 1 ); | |
/** | |
* Stores emails sent through WordPress to a log file in the content directory. | |
* | |
* @param array $args arguments passed to wp_mail() | |
* | |
* @return array arguments, unmodified | |
*/ | |
function wsu_log_wp_mail( $args ) { | |
// Only do this in a specific local environment. | |
if ( defined( 'WSU_LOCAL_CONFIG' ) && true === WSU_LOCAL_CONFIG ) { | |
$log_message = "---MESSAGE---\n" . var_export( array( date('r'), $args ), true ); | |
$fp = fopen( WP_CONTENT_DIR . '/log/wp-mail.log', 'a+' ); | |
fwrite( $fp, $log_message ); | |
fclose( $fp ); | |
} | |
return $args; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment