Created
December 21, 2010 01:25
-
-
Save mattwiebe/749336 to your computer and use it in GitHub Desktop.
A simple class to override WP's email functionality to debug/inspect what will be sent. Put in your mu-plugins directory.
This file contains 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: Mail Killer/Logger | |
Description: A simple class to override WP's email functionality to debug/inspect what will be sent. Put in your mu-plugins directory. | |
Version: 1.0 | |
Author: Matt Wiebe | |
Author URI: http://somadesign.ca/ | |
License: A "Slug" license name e.g. GPL2 | |
*/ | |
class SD_Mail_Killer { | |
private $phpmailer; | |
private $kill_email = true; // true: email will not be sent | |
private $log = true; // true: the PHPMailer Object will be written to your error_log for debugging purposes. | |
function __construct() { | |
add_action('phpmailer_init', array($this, 'replace'), 10, 1); | |
} | |
function Send() { | |
if ( ! $this->kill_email ) | |
$this->phpmailer->Send(); | |
if ( $this->log ) | |
error_log(print_r($this->phpmailer, true)); | |
do_action('sd_mail_killer', $this->phpmailer); | |
} | |
function replace($phpmailer) { | |
$this->phpmailer = $phpmailer; | |
$phpmailer = $this; | |
} | |
} | |
new SD_Mail_Killer; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment