summaryrefslogtreecommitdiff
path: root/Postman/PostmanWpMail.php
diff options
context:
space:
mode:
Diffstat (limited to 'Postman/PostmanWpMail.php')
-rw-r--r--Postman/PostmanWpMail.php29
1 files changed, 18 insertions, 11 deletions
diff --git a/Postman/PostmanWpMail.php b/Postman/PostmanWpMail.php
index 3a2b508..c108cce 100644
--- a/Postman/PostmanWpMail.php
+++ b/Postman/PostmanWpMail.php
@@ -25,6 +25,8 @@ if ( ! class_exists( 'PostmanWpMail' ) ) {
require_once 'Postman-Mail/PostmanMailEngine.php';
require_once 'Postman-Auth/PostmanAuthenticationManagerFactory.php';
require_once 'PostmanState.php';
+
+ PostmanEmailLogService::getInstance();
}
/**
@@ -95,7 +97,7 @@ if ( ! class_exists( 'PostmanWpMail' ) ) {
* @param mixed $headers
* @param mixed $attachments
*/
- private function processWpMailCall( $to, $subject, $message, $headers, $attachments ) {
+ public function processWpMailCall( $to, $subject, $message, $headers, $attachments ) {
$this->logger->trace( 'wp_mail parameters before applying WordPress wp_mail filter:' );
$this->traceParameters( $to, $subject, $message, $headers, $attachments );
@@ -199,7 +201,6 @@ if ( ! class_exists( 'PostmanWpMail' ) ) {
// apply the WordPress filters
// may impact the from address, from email, charset and content-type
$message->applyFilters();
- //do_action_ref_array( 'phpmailer_init', array( &$message ) );
// create the body parts (if they are both missing)
if ( $message->isBodyPartsEmpty() ) {
@@ -229,8 +230,13 @@ if ( ! class_exists( 'PostmanWpMail' ) ) {
}
$this->logger->debug( 'Sending mail' );
+
// may throw an exception attempting to contact the SMTP server
- $engine->send( $message );
+ if ( $send_email = apply_filters( 'post_smtp_do_send_email', true ) ) {
+ $engine->send($message);
+ } else {
+ $this->transcript = 'Bypassed By MailControl For Post SMTP';
+ }
// increment the success counter, unless we are just tesitng
if ( ! $testMode ) {
@@ -241,10 +247,10 @@ if ( ! class_exists( 'PostmanWpMail' ) ) {
// clean up
$this->postSend( $engine, $startTime, $options, $transport );
- if ( $options->getRunMode() == PostmanOptions::RUN_MODE_PRODUCTION || $options->getRunMode() == PostmanOptions::RUN_MODE_LOG_ONLY ) {
- // log the successful delivery
- PostmanEmailLogService::getInstance()->writeSuccessLog( $log, $message, $engine->getTranscript(), $transport );
- }
+ /**
+ * Do stuff after successful delivery
+ */
+ do_action( 'post_smtp_on_success', $log, $message, $engine->getTranscript(), $transport );
// return successful
return true;
@@ -263,10 +269,11 @@ if ( ! class_exists( 'PostmanWpMail' ) ) {
// clean up
$this->postSend( $engine, $startTime, $options, $transport );
- if ( $options->getRunMode() == PostmanOptions::RUN_MODE_PRODUCTION || $options->getRunMode() == PostmanOptions::RUN_MODE_LOG_ONLY ) {
- // log the failed delivery
- PostmanEmailLogService::getInstance()->writeFailureLog( $log, $message, $engine->getTranscript(), $transport, $e->getMessage() );
- }
+
+ /**
+ * Do stuff after failed delivery
+ */
+ do_action( 'post_smtp_on_failed', $log, $message, $engine->getTranscript(), $transport, $e->getMessage() );
// Fallback
if ( $this->fallback( $log, $message, $options ) ) {