summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Postman/Postman-Email-Log/PostmanEmailLogView.php3
-rw-r--r--Postman/Postman-Mail/PostmanSendGridMailEngine.php116
-rw-r--r--postman-smtp.php4
-rw-r--r--readme.txt5
4 files changed, 64 insertions, 64 deletions
diff --git a/Postman/Postman-Email-Log/PostmanEmailLogView.php b/Postman/Postman-Email-Log/PostmanEmailLogView.php
index a754a42..2db03d7 100644
--- a/Postman/Postman-Email-Log/PostmanEmailLogView.php
+++ b/Postman/Postman-Email-Log/PostmanEmailLogView.php
@@ -366,9 +366,10 @@ class PostmanEmailLogView extends WP_List_Table {
$date = sprintf( _x( '%s ago', 'A relative time as in "five days ago"', Postman::TEXT_DOMAIN ), $humanTime );
}
$meta_values = get_post_meta( $post->ID );
+ $sent_to = array_map( 'sanitize_email', explode( ',' , $meta_values ['to_header'] [0] ) );
$flattenedPost = array(
// the post title must be escaped as they are displayed in the HTML output
- 'sent_to' => sanitize_email( $meta_values ['to_header'] [0] ),
+ 'sent_to' => implode( ', ', $sent_to ),
'title' => esc_html( $post->post_title ),
// the post status must be escaped as they are displayed in the HTML output
'status' => ($post->post_excerpt != null ? esc_html( $post->post_excerpt ) : __( 'Sent', Postman::TEXT_DOMAIN )),
diff --git a/Postman/Postman-Mail/PostmanSendGridMailEngine.php b/Postman/Postman-Mail/PostmanSendGridMailEngine.php
index de6e5c3..174f38a 100644
--- a/Postman/Postman-Mail/PostmanSendGridMailEngine.php
+++ b/Postman/Postman-Mail/PostmanSendGridMailEngine.php
@@ -18,7 +18,6 @@ if ( ! class_exists( 'PostmanSendGridMailEngine' ) ) {
// the result
private $transcript;
- private $personalization;
private $apiKey;
/**
@@ -32,9 +31,6 @@ if ( ! class_exists( 'PostmanSendGridMailEngine' ) ) {
// create the logger
$this->logger = new PostmanLogger( get_class( $this ) );
-
- // create the Message
- $this->personalization = new SendGrid\Personalization();
}
/**
@@ -45,24 +41,6 @@ if ( ! class_exists( 'PostmanSendGridMailEngine' ) ) {
public function send( PostmanMessage $message ) {
$options = PostmanOptions::getInstance();
- // add the Postman signature - append it to whatever the user may have set
- if ( ! $options->isStealthModeEnabled() ) {
- $pluginData = apply_filters( 'postman_get_plugin_metadata', null );
- $this->personalization->addHeader( 'X-Mailer', sprintf( 'Postman SMTP %s for WordPress (%s)', $pluginData ['version'], 'https://wordpress.org/plugins/post-smtp/' ) );
- }
-
- // add the headers - see http://framework.zend.com/manual/1.12/en/zend.mail.additional-headers.html
- foreach ( ( array ) $message->getHeaders() as $header ) {
- $this->logger->debug( sprintf( 'Adding user header %s=%s', $header ['name'], $header ['content'] ) );
- $this->personalization->addHeader( $header ['name'], $header ['content'] );
- }
-
- // if the caller set a Content-Type header, use it
- $contentType = $message->getContentType();
- if ( ! empty( $contentType ) ) {
- $this->logger->debug( 'Some header keys are reserved. You may not include any of the following reserved headers: x-sg-id, x-sg-eid, received, dkim-signature, Content-Type, Content-Transfer-Encoding, To, From, Subject, Reply-To, CC, BCC.' );
- }
-
// add the From Header
$sender = $message->getFromAddress();
@@ -76,81 +54,99 @@ if ( ! class_exists( 'PostmanSendGridMailEngine' ) ) {
// add the to recipients
$counter = 0;
+ $emails = array();
foreach ( ( array ) $message->getToRecipients() as $recipient ) {
$recipient->log( $this->logger, 'To' );
if ( $counter == 0 ) {
- $to = new SendGrid\Email($recipient->getName(), $recipient->getEmail());
- $this->personalization->addTo( $to );
+ $to = new SendGrid\Email( $recipient->getName(), $recipient->getEmail() );
} else {
- $email = new SendGrid\Email($recipient->getName(), $recipient->getEmail());
- $this->personalization->addTo( $email );
+ $emails[] = new SendGrid\Email( $recipient->getName(), $recipient->getEmail() );
}
$counter++;
}
- // add the cc recipients
- foreach ( ( array ) $message->getCcRecipients() as $recipient ) {
- $recipient->log( $this->logger, 'Cc' );
- $this->personalization->addCc( $recipient->getEmail(), $recipient->getName() );
- }
-
- // add the bcc recipients
- foreach ( ( array ) $message->getBccRecipients() as $recipient ) {
- $recipient->log( $this->logger, 'Bcc' );
- $this->personalization->addBcc( $recipient->getEmail(), $recipient->getName() );
- }
-
- // add the messageId
- $messageId = $message->getMessageId();
- if ( ! empty( $messageId ) ) {
- $this->personalization->addHeader( 'message-id', $messageId );
- }
-
// add the subject
if ( null !== $message->getSubject() ) {
$subject = $message->getSubject();
}
// add the message content
-
$textPart = $message->getBodyTextPart();
if ( ! empty( $textPart ) ) {
$this->logger->debug( 'Adding body as text' );
- $content = new SendGrid\Content("text/plain", $textPart);
+ $content = new SendGrid\Content( 'text/plain', $textPart );
}
$htmlPart = $message->getBodyHtmlPart();
if ( ! empty( $htmlPart ) ) {
$this->logger->debug( 'Adding body as html' );
- $content = new SendGrid\Content("text/html", $htmlPart);
+ $content = new SendGrid\Content( 'text/html', $htmlPart );
}
- // add attachments
- $this->logger->debug( 'Adding attachments' );
-
- $mail = new SendGrid\Mail($from, $subject, $to, $content);
- $mail->addPersonalization($this->personalization);
+ $mail = new SendGrid\Mail( $from, $subject, $to, $content );
+ foreach ( $emails as $email ) {
+ $mail->personalization[0]->addTo( $email );
+ }
// add the reply-to
$replyTo = $message->getReplyTo();
// $replyTo is null or a PostmanEmailAddress object
if ( isset( $replyTo ) ) {
$reply_to = new SendGrid\ReplyTo( $replyTo->getEmail(), $replyTo->getName() );
- $mail->setReplyTo($reply_to);
+ $mail->setReplyTo( $reply_to );
+ }
+
+ // add the Postman signature - append it to whatever the user may have set
+ if ( ! $options->isStealthModeEnabled() ) {
+ $pluginData = apply_filters( 'postman_get_plugin_metadata', null );
+ $mail->personalization[0]->addHeader( 'X-Mailer', sprintf( 'Postman SMTP %s for WordPress (%s)', $pluginData ['version'], 'https://wordpress.org/plugins/post-smtp/' ) );
+ }
+
+ // add the headers - see http://framework.zend.com/manual/1.12/en/zend.mail.additional-headers.html
+ foreach ( ( array ) $message->getHeaders() as $header ) {
+ $this->logger->debug( sprintf( 'Adding user header %s=%s', $header ['name'], $header ['content'] ) );
+ $mail->personalization[0]->addHeader( $header ['name'], $header ['content'] );
}
+ // if the caller set a Content-Type header, use it
+ $contentType = $message->getContentType();
+ if ( ! empty( $contentType ) ) {
+ $this->logger->debug( 'Some header keys are reserved. You may not include any of the following reserved headers: x-sg-id, x-sg-eid, received, dkim-signature, Content-Type, Content-Transfer-Encoding, To, From, Subject, Reply-To, CC, BCC.' );
+ }
+
+ // add the cc recipients
+ foreach ( ( array ) $message->getCcRecipients() as $recipient ) {
+ $recipient->log( $this->logger, 'Cc' );
+ $mail->personalization[0]->addCc( $recipient->getEmail(), $recipient->getName() );
+ }
+
+ // add the bcc recipients
+ foreach ( ( array ) $message->getBccRecipients() as $recipient ) {
+ $recipient->log( $this->logger, 'Bcc' );
+ $mail->personalization[0]->addBcc( $recipient->getEmail(), $recipient->getName() );
+ }
+
+ // add the messageId
+ $messageId = $message->getMessageId();
+ if ( ! empty( $messageId ) ) {
+ $mail->personalization[0]->addHeader( 'message-id', $messageId );
+ }
+
+ // add attachments
+ $this->logger->debug( 'Adding attachments' );
+
$attachments = $this->addAttachmentsToMail( $message );
foreach ( $attachments as $index => $attachment ) {
$attach = new SendGrid\Attachment();
- $attach->setContent($attachment['content']);
- $attach->setType($attachment['type']);
- $attach->setFilename($attachment['file_name']);
- $attach->setDisposition("attachment");
- $attach->setContentId($attachment['id']);
- $mail->addAttachment($attach);
+ $attach->setContent( $attachment['content'] );
+ $attach->setType( $attachment['type'] );
+ $attach->setFilename( $attachment['file_name'] );
+ $attach->setDisposition( 'attachment' );
+ $attach->setContentId( $attachment['id'] );
+ $mail->addAttachment( $attach );
}
try {
@@ -165,7 +161,7 @@ if ( ! class_exists( 'PostmanSendGridMailEngine' ) ) {
$this->logger->debug( 'Sending mail' );
}
- $response = $sendgrid->client->mail()->send()->post($mail);
+ $response = $sendgrid->client->mail()->send()->post( $mail );
if ( $this->logger->isInfo() ) {
$this->logger->info( );
}
diff --git a/postman-smtp.php b/postman-smtp.php
index a40bc3e..7b557ef 100644
--- a/postman-smtp.php
+++ b/postman-smtp.php
@@ -4,7 +4,7 @@
* Plugin Name: Post SMTP
* Plugin URI: https://wordpress.org/plugins/post-smtp/
* Description: Email not reliable? Post SMTP is the first and only WordPress SMTP plugin to implement OAuth 2.0 for Gmail, Hotmail and Yahoo Mail. Setup is a breeze with the Configuration Wizard and integrated Port Tester. Enjoy worry-free delivery even if your password changes!
- * Version: 1.8.1
+ * Version: 1.8.2
* Author: Jason Hendriks, Yehuda Hassine
* Text Domain: post-smtp
* Author URI: https://postmansmtp.com
@@ -71,5 +71,5 @@ function post_start( $startingMemory ) {
*/
function post_setupPostman() {
require_once 'Postman/Postman.php';
- $kevinCostner = new Postman( __FILE__, '1.8.1' );
+ $kevinCostner = new Postman( __FILE__, '1.8.2' );
}
diff --git a/readme.txt b/readme.txt
index e224c2f..7297e68 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: 4.9.4
-Stable tag: 1.8.1
+Stable tag: 1.8.2
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -284,6 +284,9 @@ To avoid being flagged as spam, you need to prove your email isn't forged. On a
== Changelog ==
+= 1.8.2 - 2017-12-24
+* Fix: SendGrid API Call Structure
+
= 1.8.1 - 2017-12-24
* New: Sendgrid API & Client Version 6
* New: Add email log 'send to' column