diff options
author | yehudah <yehudah@b8457f37-d9ea-0310-8a92-e5e31aec5664> | 2020-01-20 21:09:16 +0000 |
---|---|---|
committer | yehudah <yehudah@b8457f37-d9ea-0310-8a92-e5e31aec5664> | 2020-01-20 21:09:16 +0000 |
commit | 5e09c090a23853cf3f174b2f6459520668e0d039 (patch) | |
tree | d4d8bcc1f814aa54d759ebca3ac13fcb55589be6 /Postman | |
parent | 8c9462e6ab86a80ad79ea478601a38c76915548e (diff) | |
download | Post-SMTP-5e09c090a23853cf3f174b2f6459520668e0d039.zip |
fix duplicate in sendgrid and duplicate failed log
Diffstat (limited to 'Postman')
-rw-r--r-- | Postman/Phpmailer/PostsmtpMailer.php | 2 | ||||
-rw-r--r-- | Postman/Postman-Mail/PostmanSendGridMailEngine.php | 21 |
2 files changed, 16 insertions, 7 deletions
diff --git a/Postman/Phpmailer/PostsmtpMailer.php b/Postman/Phpmailer/PostsmtpMailer.php index c86a0a0..eb0246f 100644 --- a/Postman/Phpmailer/PostsmtpMailer.php +++ b/Postman/Phpmailer/PostsmtpMailer.php @@ -125,8 +125,6 @@ class PostsmtpMailer extends PHPMailer { $this->mailHeader = ''; - do_action( 'post_smtp_on_failed', $log, $postmanMessage, $this->transcript, $transport, $exc->getMessage() ); - $this->setError($exc->getMessage()); if ($this->exceptions) { throw $exc; diff --git a/Postman/Postman-Mail/PostmanSendGridMailEngine.php b/Postman/Postman-Mail/PostmanSendGridMailEngine.php index 2ffb8e2..336bd89 100644 --- a/Postman/Postman-Mail/PostmanSendGridMailEngine.php +++ b/Postman/Postman-Mail/PostmanSendGridMailEngine.php @@ -57,9 +57,14 @@ if ( ! class_exists( 'PostmanSendGridMailEngine' ) ) { // now log it $sender->log( $this->logger, 'From' ); + $duplicates = array(); + // add the to recipients foreach ( ( array ) $message->getToRecipients() as $recipient ) { - $emails[] = new \SendGrid\Mail\To($recipient->getEmail(), $recipient->getName() ); + if ( ! in_array( $recipient->getEmail(), $duplicates ) ) { + $emails[] = new \SendGrid\Mail\To( $recipient->getEmail(), $recipient->getName() ); + $duplicates[] = $recipient->getEmail(); + } } $email->addTos( $emails ); @@ -111,16 +116,22 @@ if ( ! class_exists( 'PostmanSendGridMailEngine' ) ) { // add the cc recipients $ccEmails = array(); foreach ( ( array ) $message->getCcRecipients() as $recipient ) { - $recipient->log( $this->logger, 'Cc' ); - $ccEmails[] = new \SendGrid\Mail\Cc( $recipient->getEmail(), $recipient->getName() ); + if ( ! in_array( $recipient->getEmail(), $duplicates ) ) { + $recipient->log($this->logger, 'Cc'); + $ccEmails[] = new \SendGrid\Mail\Cc($recipient->getEmail(), $recipient->getName()); + $duplicates[] = $recipient->getEmail(); + } } $email->addCcs($ccEmails); // add the bcc recipients $bccEmails = array(); foreach ( ( array ) $message->getBccRecipients() as $recipient ) { - $recipient->log($this->logger, 'Bcc'); - $bccEmails[] = new \SendGrid\Mail\Bcc( $recipient->getEmail(), $recipient->getName() ); + if ( ! in_array( $recipient->getEmail(), $duplicates ) ) { + $recipient->log($this->logger, 'Bcc'); + $bccEmails[] = new \SendGrid\Mail\Bcc($recipient->getEmail(), $recipient->getName()); + $duplicates[] = $recipient->getEmail(); + } } $email->addBccs($bccEmails); |