summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryehudah <yehudah@b8457f37-d9ea-0310-8a92-e5e31aec5664>2020-08-11 20:43:01 +0000
committeryehudah <yehudah@b8457f37-d9ea-0310-8a92-e5e31aec5664>2020-08-11 20:43:01 +0000
commite3656d7a8c63b7198bb08c6b7b90f2c7c5b16e98 (patch)
tree77a414082c7c8d496a9749459f5c193ecb0ad7f2
parentdf4cdf1cbae42de7b279f474e2b27fa719a90429 (diff)
downloadPost-SMTP-e3656d7a8c63b7198bb08c6b7b90f2c7c5b16e98.zip
phpmailer rror
-rw-r--r--Postman/Phpmailer/PostsmtpMailer.php221
-rw-r--r--postman-smtp.php2
-rw-r--r--readme.txt2
3 files changed, 110 insertions, 115 deletions
diff --git a/Postman/Phpmailer/PostsmtpMailer.php b/Postman/Phpmailer/PostsmtpMailer.php
index 91f5122..b8227d5 100644
--- a/Postman/Phpmailer/PostsmtpMailer.php
+++ b/Postman/Phpmailer/PostsmtpMailer.php
@@ -1,159 +1,154 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
- exit; // Exit if accessed directly
+ exit; // Exit if accessed directly
}
if ( ! class_exists( 'PHPMailer', false ) ) {
- require_once ABSPATH . WPINC . '/PHPMailer/PHPMailer.php';
- require_once ABSPATH . WPINC . '/PHPMailer/SMTP.php';
- require_once ABSPATH . WPINC . '/PHPMailer/Exception.php';
+ require_once ABSPATH . WPINC . '/class-phpmailer.php';
}
-use PHPMailer\PHPMailer\PHPMailer;
-use PHPMailer\PHPMailer\Exception;
-
add_action('plugins_loaded', function() {
- global $phpmailer;
+ global $phpmailer;
- $phpmailer = new PostsmtpMailer(true);
+ $phpmailer = new PostsmtpMailer(true);
});
class PostsmtpMailer extends PHPMailer {
- private $mail_args = array();
+ private $mail_args = array();
- private $options;
+ private $options;
- private $error;
+ private $error;
- private $transcript = '';
+ private $transcript = '';
- public function __construct($exceptions = null)
- {
- parent::__construct($exceptions);
+ public function __construct($exceptions = null)
+ {
+ parent::__construct($exceptions);
- $this->set_vars();
- $this->hooks();
+ $this->set_vars();
+ $this->hooks();
- }
+ }
- public function set_vars() {
- $this->options = PostmanOptions::getInstance();
- $this->Debugoutput = function($str, $level) {
- $this->transcript .= $str;
- };
- }
+ public function set_vars() {
+ $this->options = PostmanOptions::getInstance();
+ $this->Debugoutput = function($str, $level) {
+ $this->transcript .= $str;
+ };
+ }
- public function hooks() {
- add_filter( 'wp_mail', array( $this, 'get_mail_args' ) );
- if ( $this->options->getTransportType() == 'smtp' ) {
- add_action( 'phpmailer_init', array( $this, 'phpmailer_smtp_init' ), 999 );
- }
- }
+ public function hooks() {
+ add_filter( 'wp_mail', array( $this, 'get_mail_args' ) );
+ if ( $this->options->getTransportType() == 'smtp' ) {
+ add_action( 'phpmailer_init', array( $this, 'phpmailer_smtp_init' ), 999 );
+ }
+ }
- public function get_mail_args( $atts ) {
- $this->mail_args = array();
- $this->mail_args[] = $atts['to'];
- $this->mail_args[] = $atts['subject'];
- $this->mail_args[] = $atts['message'];
- $this->mail_args[] = $atts['headers'];
- $this->mail_args[] = $atts['attachments'];
+ public function get_mail_args( $atts ) {
+ $this->mail_args = array();
+ $this->mail_args[] = $atts['to'];
+ $this->mail_args[] = $atts['subject'];
+ $this->mail_args[] = $atts['message'];
+ $this->mail_args[] = $atts['headers'];
+ $this->mail_args[] = $atts['attachments'];
- return $atts;
- }
+ return $atts;
+ }
- /**
- * @param PHPMailer $mail
- */
- public function phpmailer_smtp_init($mail) {
- $mail->SMTPDebug = 3;
- $mail->isSMTP();
- $mail->Host = $this->options->getHostname();
+ /**
+ * @param PHPMailer $mail
+ */
+ public function phpmailer_smtp_init($mail) {
+ $mail->SMTPDebug = 3;
+ $mail->isSMTP();
+ $mail->Host = $this->options->getHostname();
- if ( $this->options->getAuthenticationType() !== 'none' ) {
- $mail->SMTPAuth = true;
- $mail->Username = $this->options->getUsername();
- $mail->Password = $this->options->getPassword();
- }
+ if ( $this->options->getAuthenticationType() !== 'none' ) {
+ $mail->SMTPAuth = true;
+ $mail->Username = $this->options->getUsername();
+ $mail->Password = $this->options->getPassword();
+ }
- if ( $this->options->getEncryptionType() !== 'none' ) {
- $mail->SMTPSecure = $this->options->getEncryptionType();
- }
+ if ( $this->options->getEncryptionType() !== 'none' ) {
+ $mail->SMTPSecure = $this->options->getEncryptionType();
+ }
- $mail->Port = $this->options->getPort();
+ $mail->Port = $this->options->getPort();
- if ( $this->options->isPluginSenderEmailEnforced() ) {
- $mail->setFrom( $this->options->getMessageSenderEmail() , $this->options->getMessageSenderName () );
- }
- }
+ if ( $this->options->isPluginSenderEmailEnforced() ) {
+ $mail->setFrom( $this->options->getMessageSenderEmail() , $this->options->getMessageSenderName () );
+ }
+ }
- public function send()
- {
- require_once dirname(__DIR__) . '/PostmanWpMail.php';
+ public function send()
+ {
+ require_once dirname(__DIR__) . '/PostmanWpMail.php';
- // create a PostmanWpMail instance
- $postmanWpMail = new PostmanWpMail();
- $postmanWpMail->init();
+ // create a PostmanWpMail instance
+ $postmanWpMail = new PostmanWpMail();
+ $postmanWpMail->init();
- list($to, $subject, $body, $headers, $attachments) = array_pad( $this->mail_args, 5, null );
+ list($to, $subject, $body, $headers, $attachments) = array_pad( $this->mail_args, 5, null );
- // build the message
- $postmanMessage = $postmanWpMail->processWpMailCall( $to, $subject, $body, $headers, $attachments );
+ // build the message
+ $postmanMessage = $postmanWpMail->processWpMailCall( $to, $subject, $body, $headers, $attachments );
- // build the email log entry
- $log = new PostmanEmailLog();
- $log->originalTo = $to;
- $log->originalSubject = $subject;
- $log->originalMessage = $body;
- $log->originalHeaders = $headers;
+ // build the email log entry
+ $log = new PostmanEmailLog();
+ $log->originalTo = $to;
+ $log->originalSubject = $subject;
+ $log->originalMessage = $body;
+ $log->originalHeaders = $headers;
- // get the transport and create the transportConfig and engine
- $transport = PostmanTransportRegistry::getInstance()->getActiveTransport();
+ // get the transport and create the transportConfig and engine
+ $transport = PostmanTransportRegistry::getInstance()->getActiveTransport();
- add_filter( 'postman_wp_mail_result', [ $this, 'postman_wp_mail_result' ] );
+ add_filter( 'postman_wp_mail_result', [ $this, 'postman_wp_mail_result' ] );
- try {
+ try {
- if ( $send_email = apply_filters( 'post_smtp_do_send_email', true ) ) {
- $result = $this->options->getTransportType() !== 'smtp' ?
- $postmanWpMail->send( $to, $subject, $body, $headers, $attachments ) :
- $this->sendSmtp();
- }
+ if ( $send_email = apply_filters( 'post_smtp_do_send_email', true ) ) {
+ $result = $this->options->getTransportType() !== 'smtp' ?
+ $postmanWpMail->send( $to, $subject, $body, $headers, $attachments ) :
+ $this->sendSmtp();
+ }
- do_action( 'post_smtp_on_success', $log, $postmanMessage, $this->transcript, $transport );
+ do_action( 'post_smtp_on_success', $log, $postmanMessage, $this->transcript, $transport );
- return $result;
+ return $result;
- } catch (Exception $exc) {
+ } catch (phpmailerException $exc) {
- $this->error = $exc;
-
- $this->mailHeader = '';
+ $this->error = $exc;
+
+ $this->mailHeader = '';
- $this->setError($exc->getMessage());
- if ($this->exceptions) {
- throw $exc;
- }
- return false;
- }
-
- }
-
- public function sendSmtp() {
- if (!$this->preSend()) {
- return false;
- }
- return $this->postSend();
- }
+ $this->setError($exc->getMessage());
+ if ($this->exceptions) {
+ throw $exc;
+ }
+ return false;
+ }
+
+ }
+
+ public function sendSmtp() {
+ if (!$this->preSend()) {
+ return false;
+ }
+ return $this->postSend();
+ }
- public function postman_wp_mail_result() {
- $result = [
- 'time' => '',
- 'exception' => $this->error,
- 'transcript' => $this->transcript,
- ];
- return $result;
- }
+ public function postman_wp_mail_result() {
+ $result = [
+ 'time' => '',
+ 'exception' => $this->error,
+ 'transcript' => $this->transcript,
+ ];
+ return $result;
+ }
} \ No newline at end of file
diff --git a/postman-smtp.php b/postman-smtp.php
index 9868686..6994870 100644
--- a/postman-smtp.php
+++ b/postman-smtp.php
@@ -35,7 +35,7 @@ if ( ! defined( 'ABSPATH' ) ) {
define( 'POST_SMTP_BASE', __FILE__ );
define( 'POST_SMTP_PATH', __DIR__ );
define( 'POST_SMTP_URL', plugins_url('', POST_SMTP_BASE ) );
-define( 'POST_SMTP_VER', '2.0.13' );
+define( 'POST_SMTP_VER', '2.0.14' );
define( 'POST_SMTP_SHOW_RELEASE_MESSAGE', true );
define( 'POST_SMTP_RELEASE_MESSAGE', "I have released a new Google Analytics AIO plugin, if you liked it please leave a review." );
define( 'POST_SMTP_RELEASE_URL', 'https://wordpress.org/plugins/metrics-query/' );
diff --git a/readme.txt b/readme.txt
index 6975933..ba3f438 100644
--- a/readme.txt
+++ b/readme.txt
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=yehuda@m
Tags: postman smtp, postman, smtp, email, mail, mailer, email log, oauth2, gmail, google apps, hotmail, yahoo, mandrill api, sendgrid api, elastic email, office365, mailgun
Requires at least: 3.9
Tested up to: 5.5
-Stable tag: 2.0.13
+Stable tag: 2.0.14
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html