diff options
author | yehudah <yehudah@b8457f37-d9ea-0310-8a92-e5e31aec5664> | 2019-11-25 09:25:43 +0000 |
---|---|---|
committer | yehudah <yehudah@b8457f37-d9ea-0310-8a92-e5e31aec5664> | 2019-11-25 09:25:43 +0000 |
commit | b5fd728e37aa2a9c7a5f37e8dead0a95117d541b (patch) | |
tree | a7158edc5e4e576e0377f078dabc87c699315c62 /Postman/PostmanWpMail.php | |
parent | c61784411988d36d9bbd93cd3a97e773990af342 (diff) | |
download | Post-SMTP-b5fd728e37aa2a9c7a5f37e8dead0a95117d541b.zip |
phpmailer delivery improvments
bug fixes
add option to disable notifications
fix Invalid “Reply-To” e-mail address
Diffstat (limited to 'Postman/PostmanWpMail.php')
-rw-r--r-- | Postman/PostmanWpMail.php | 29 |
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 ) ) { |