Version Description
- 2017-12-24
- Fix: SendGrid API Call Structure
Download this release
Release Info
Developer | yehudah |
Plugin | Post SMTP Mailer/Email Log |
Version | 1.8.2 |
Comparing to | |
See all releases |
Code changes from version 1.8.1 to 1.8.2
Postman/Postman-Email-Log/PostmanEmailLogView.php
CHANGED
@@ -366,9 +366,10 @@ class PostmanEmailLogView extends WP_List_Table {
|
|
366 |
$date = sprintf( _x( '%s ago', 'A relative time as in "five days ago"', Postman::TEXT_DOMAIN ), $humanTime );
|
367 |
}
|
368 |
$meta_values = get_post_meta( $post->ID );
|
|
|
369 |
$flattenedPost = array(
|
370 |
// the post title must be escaped as they are displayed in the HTML output
|
371 |
-
'sent_to' =>
|
372 |
'title' => esc_html( $post->post_title ),
|
373 |
// the post status must be escaped as they are displayed in the HTML output
|
374 |
'status' => ($post->post_excerpt != null ? esc_html( $post->post_excerpt ) : __( 'Sent', Postman::TEXT_DOMAIN )),
|
366 |
$date = sprintf( _x( '%s ago', 'A relative time as in "five days ago"', Postman::TEXT_DOMAIN ), $humanTime );
|
367 |
}
|
368 |
$meta_values = get_post_meta( $post->ID );
|
369 |
+
$sent_to = array_map( 'sanitize_email', explode( ',' , $meta_values ['to_header'] [0] ) );
|
370 |
$flattenedPost = array(
|
371 |
// the post title must be escaped as they are displayed in the HTML output
|
372 |
+
'sent_to' => implode( ', ', $sent_to ),
|
373 |
'title' => esc_html( $post->post_title ),
|
374 |
// the post status must be escaped as they are displayed in the HTML output
|
375 |
'status' => ($post->post_excerpt != null ? esc_html( $post->post_excerpt ) : __( 'Sent', Postman::TEXT_DOMAIN )),
|
Postman/Postman-Mail/PostmanSendGridMailEngine.php
CHANGED
@@ -18,7 +18,6 @@ if ( ! class_exists( 'PostmanSendGridMailEngine' ) ) {
|
|
18 |
// the result
|
19 |
private $transcript;
|
20 |
|
21 |
-
private $personalization;
|
22 |
private $apiKey;
|
23 |
|
24 |
/**
|
@@ -32,9 +31,6 @@ if ( ! class_exists( 'PostmanSendGridMailEngine' ) ) {
|
|
32 |
|
33 |
// create the logger
|
34 |
$this->logger = new PostmanLogger( get_class( $this ) );
|
35 |
-
|
36 |
-
// create the Message
|
37 |
-
$this->personalization = new SendGrid\Personalization();
|
38 |
}
|
39 |
|
40 |
/**
|
@@ -45,24 +41,6 @@ if ( ! class_exists( 'PostmanSendGridMailEngine' ) ) {
|
|
45 |
public function send( PostmanMessage $message ) {
|
46 |
$options = PostmanOptions::getInstance();
|
47 |
|
48 |
-
// add the Postman signature - append it to whatever the user may have set
|
49 |
-
if ( ! $options->isStealthModeEnabled() ) {
|
50 |
-
$pluginData = apply_filters( 'postman_get_plugin_metadata', null );
|
51 |
-
$this->personalization->addHeader( 'X-Mailer', sprintf( 'Postman SMTP %s for WordPress (%s)', $pluginData ['version'], 'https://wordpress.org/plugins/post-smtp/' ) );
|
52 |
-
}
|
53 |
-
|
54 |
-
// add the headers - see http://framework.zend.com/manual/1.12/en/zend.mail.additional-headers.html
|
55 |
-
foreach ( ( array ) $message->getHeaders() as $header ) {
|
56 |
-
$this->logger->debug( sprintf( 'Adding user header %s=%s', $header ['name'], $header ['content'] ) );
|
57 |
-
$this->personalization->addHeader( $header ['name'], $header ['content'] );
|
58 |
-
}
|
59 |
-
|
60 |
-
// if the caller set a Content-Type header, use it
|
61 |
-
$contentType = $message->getContentType();
|
62 |
-
if ( ! empty( $contentType ) ) {
|
63 |
-
$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.' );
|
64 |
-
}
|
65 |
-
|
66 |
// add the From Header
|
67 |
$sender = $message->getFromAddress();
|
68 |
|
@@ -76,81 +54,99 @@ if ( ! class_exists( 'PostmanSendGridMailEngine' ) ) {
|
|
76 |
|
77 |
// add the to recipients
|
78 |
$counter = 0;
|
|
|
79 |
foreach ( ( array ) $message->getToRecipients() as $recipient ) {
|
80 |
$recipient->log( $this->logger, 'To' );
|
81 |
if ( $counter == 0 ) {
|
82 |
-
$to = new SendGrid\Email($recipient->getName(), $recipient->getEmail());
|
83 |
-
$this->personalization->addTo( $to );
|
84 |
} else {
|
85 |
-
$
|
86 |
-
$this->personalization->addTo( $email );
|
87 |
}
|
88 |
|
89 |
$counter++;
|
90 |
}
|
91 |
|
92 |
-
// add the cc recipients
|
93 |
-
foreach ( ( array ) $message->getCcRecipients() as $recipient ) {
|
94 |
-
$recipient->log( $this->logger, 'Cc' );
|
95 |
-
$this->personalization->addCc( $recipient->getEmail(), $recipient->getName() );
|
96 |
-
}
|
97 |
-
|
98 |
-
// add the bcc recipients
|
99 |
-
foreach ( ( array ) $message->getBccRecipients() as $recipient ) {
|
100 |
-
$recipient->log( $this->logger, 'Bcc' );
|
101 |
-
$this->personalization->addBcc( $recipient->getEmail(), $recipient->getName() );
|
102 |
-
}
|
103 |
-
|
104 |
-
// add the messageId
|
105 |
-
$messageId = $message->getMessageId();
|
106 |
-
if ( ! empty( $messageId ) ) {
|
107 |
-
$this->personalization->addHeader( 'message-id', $messageId );
|
108 |
-
}
|
109 |
-
|
110 |
// add the subject
|
111 |
if ( null !== $message->getSubject() ) {
|
112 |
$subject = $message->getSubject();
|
113 |
}
|
114 |
|
115 |
// add the message content
|
116 |
-
|
117 |
$textPart = $message->getBodyTextPart();
|
118 |
if ( ! empty( $textPart ) ) {
|
119 |
$this->logger->debug( 'Adding body as text' );
|
120 |
-
$content = new SendGrid\Content(
|
121 |
}
|
122 |
|
123 |
$htmlPart = $message->getBodyHtmlPart();
|
124 |
if ( ! empty( $htmlPart ) ) {
|
125 |
$this->logger->debug( 'Adding body as html' );
|
126 |
-
$content = new SendGrid\Content(
|
127 |
}
|
128 |
|
129 |
-
|
130 |
-
$this->logger->debug( 'Adding attachments' );
|
131 |
-
|
132 |
-
$mail = new SendGrid\Mail($from, $subject, $to, $content);
|
133 |
-
$mail->addPersonalization($this->personalization);
|
134 |
|
|
|
|
|
|
|
135 |
|
136 |
// add the reply-to
|
137 |
$replyTo = $message->getReplyTo();
|
138 |
// $replyTo is null or a PostmanEmailAddress object
|
139 |
if ( isset( $replyTo ) ) {
|
140 |
$reply_to = new SendGrid\ReplyTo( $replyTo->getEmail(), $replyTo->getName() );
|
141 |
-
$mail->setReplyTo($reply_to);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
142 |
}
|
143 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
144 |
$attachments = $this->addAttachmentsToMail( $message );
|
145 |
|
146 |
foreach ( $attachments as $index => $attachment ) {
|
147 |
$attach = new SendGrid\Attachment();
|
148 |
-
$attach->setContent($attachment['content']);
|
149 |
-
$attach->setType($attachment['type']);
|
150 |
-
$attach->setFilename($attachment['file_name']);
|
151 |
-
$attach->setDisposition(
|
152 |
-
$attach->setContentId($attachment['id']);
|
153 |
-
$mail->addAttachment($attach);
|
154 |
}
|
155 |
|
156 |
try {
|
@@ -165,7 +161,7 @@ if ( ! class_exists( 'PostmanSendGridMailEngine' ) ) {
|
|
165 |
$this->logger->debug( 'Sending mail' );
|
166 |
}
|
167 |
|
168 |
-
$response = $sendgrid->client->mail()->send()->post($mail);
|
169 |
if ( $this->logger->isInfo() ) {
|
170 |
$this->logger->info( );
|
171 |
}
|
18 |
// the result
|
19 |
private $transcript;
|
20 |
|
|
|
21 |
private $apiKey;
|
22 |
|
23 |
/**
|
31 |
|
32 |
// create the logger
|
33 |
$this->logger = new PostmanLogger( get_class( $this ) );
|
|
|
|
|
|
|
34 |
}
|
35 |
|
36 |
/**
|
41 |
public function send( PostmanMessage $message ) {
|
42 |
$options = PostmanOptions::getInstance();
|
43 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
// add the From Header
|
45 |
$sender = $message->getFromAddress();
|
46 |
|
54 |
|
55 |
// add the to recipients
|
56 |
$counter = 0;
|
57 |
+
$emails = array();
|
58 |
foreach ( ( array ) $message->getToRecipients() as $recipient ) {
|
59 |
$recipient->log( $this->logger, 'To' );
|
60 |
if ( $counter == 0 ) {
|
61 |
+
$to = new SendGrid\Email( $recipient->getName(), $recipient->getEmail() );
|
|
|
62 |
} else {
|
63 |
+
$emails[] = new SendGrid\Email( $recipient->getName(), $recipient->getEmail() );
|
|
|
64 |
}
|
65 |
|
66 |
$counter++;
|
67 |
}
|
68 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
// add the subject
|
70 |
if ( null !== $message->getSubject() ) {
|
71 |
$subject = $message->getSubject();
|
72 |
}
|
73 |
|
74 |
// add the message content
|
|
|
75 |
$textPart = $message->getBodyTextPart();
|
76 |
if ( ! empty( $textPart ) ) {
|
77 |
$this->logger->debug( 'Adding body as text' );
|
78 |
+
$content = new SendGrid\Content( 'text/plain', $textPart );
|
79 |
}
|
80 |
|
81 |
$htmlPart = $message->getBodyHtmlPart();
|
82 |
if ( ! empty( $htmlPart ) ) {
|
83 |
$this->logger->debug( 'Adding body as html' );
|
84 |
+
$content = new SendGrid\Content( 'text/html', $htmlPart );
|
85 |
}
|
86 |
|
87 |
+
$mail = new SendGrid\Mail( $from, $subject, $to, $content );
|
|
|
|
|
|
|
|
|
88 |
|
89 |
+
foreach ( $emails as $email ) {
|
90 |
+
$mail->personalization[0]->addTo( $email );
|
91 |
+
}
|
92 |
|
93 |
// add the reply-to
|
94 |
$replyTo = $message->getReplyTo();
|
95 |
// $replyTo is null or a PostmanEmailAddress object
|
96 |
if ( isset( $replyTo ) ) {
|
97 |
$reply_to = new SendGrid\ReplyTo( $replyTo->getEmail(), $replyTo->getName() );
|
98 |
+
$mail->setReplyTo( $reply_to );
|
99 |
+
}
|
100 |
+
|
101 |
+
// add the Postman signature - append it to whatever the user may have set
|
102 |
+
if ( ! $options->isStealthModeEnabled() ) {
|
103 |
+
$pluginData = apply_filters( 'postman_get_plugin_metadata', null );
|
104 |
+
$mail->personalization[0]->addHeader( 'X-Mailer', sprintf( 'Postman SMTP %s for WordPress (%s)', $pluginData ['version'], 'https://wordpress.org/plugins/post-smtp/' ) );
|
105 |
+
}
|
106 |
+
|
107 |
+
// add the headers - see http://framework.zend.com/manual/1.12/en/zend.mail.additional-headers.html
|
108 |
+
foreach ( ( array ) $message->getHeaders() as $header ) {
|
109 |
+
$this->logger->debug( sprintf( 'Adding user header %s=%s', $header ['name'], $header ['content'] ) );
|
110 |
+
$mail->personalization[0]->addHeader( $header ['name'], $header ['content'] );
|
111 |
}
|
112 |
|
113 |
+
// if the caller set a Content-Type header, use it
|
114 |
+
$contentType = $message->getContentType();
|
115 |
+
if ( ! empty( $contentType ) ) {
|
116 |
+
$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.' );
|
117 |
+
}
|
118 |
+
|
119 |
+
// add the cc recipients
|
120 |
+
foreach ( ( array ) $message->getCcRecipients() as $recipient ) {
|
121 |
+
$recipient->log( $this->logger, 'Cc' );
|
122 |
+
$mail->personalization[0]->addCc( $recipient->getEmail(), $recipient->getName() );
|
123 |
+
}
|
124 |
+
|
125 |
+
// add the bcc recipients
|
126 |
+
foreach ( ( array ) $message->getBccRecipients() as $recipient ) {
|
127 |
+
$recipient->log( $this->logger, 'Bcc' );
|
128 |
+
$mail->personalization[0]->addBcc( $recipient->getEmail(), $recipient->getName() );
|
129 |
+
}
|
130 |
+
|
131 |
+
// add the messageId
|
132 |
+
$messageId = $message->getMessageId();
|
133 |
+
if ( ! empty( $messageId ) ) {
|
134 |
+
$mail->personalization[0]->addHeader( 'message-id', $messageId );
|
135 |
+
}
|
136 |
+
|
137 |
+
// add attachments
|
138 |
+
$this->logger->debug( 'Adding attachments' );
|
139 |
+
|
140 |
$attachments = $this->addAttachmentsToMail( $message );
|
141 |
|
142 |
foreach ( $attachments as $index => $attachment ) {
|
143 |
$attach = new SendGrid\Attachment();
|
144 |
+
$attach->setContent( $attachment['content'] );
|
145 |
+
$attach->setType( $attachment['type'] );
|
146 |
+
$attach->setFilename( $attachment['file_name'] );
|
147 |
+
$attach->setDisposition( 'attachment' );
|
148 |
+
$attach->setContentId( $attachment['id'] );
|
149 |
+
$mail->addAttachment( $attach );
|
150 |
}
|
151 |
|
152 |
try {
|
161 |
$this->logger->debug( 'Sending mail' );
|
162 |
}
|
163 |
|
164 |
+
$response = $sendgrid->client->mail()->send()->post( $mail );
|
165 |
if ( $this->logger->isInfo() ) {
|
166 |
$this->logger->info( );
|
167 |
}
|
postman-smtp.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Plugin Name: Post SMTP
|
5 |
* Plugin URI: https://wordpress.org/plugins/post-smtp/
|
6 |
* 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!
|
7 |
-
* Version: 1.8.
|
8 |
* Author: Jason Hendriks, Yehuda Hassine
|
9 |
* Text Domain: post-smtp
|
10 |
* Author URI: https://postmansmtp.com
|
@@ -71,5 +71,5 @@ function post_start( $startingMemory ) {
|
|
71 |
*/
|
72 |
function post_setupPostman() {
|
73 |
require_once 'Postman/Postman.php';
|
74 |
-
$kevinCostner = new Postman( __FILE__, '1.8.
|
75 |
}
|
4 |
* Plugin Name: Post SMTP
|
5 |
* Plugin URI: https://wordpress.org/plugins/post-smtp/
|
6 |
* 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!
|
7 |
+
* Version: 1.8.2
|
8 |
* Author: Jason Hendriks, Yehuda Hassine
|
9 |
* Text Domain: post-smtp
|
10 |
* Author URI: https://postmansmtp.com
|
71 |
*/
|
72 |
function post_setupPostman() {
|
73 |
require_once 'Postman/Postman.php';
|
74 |
+
$kevinCostner = new Postman( __FILE__, '1.8.2' );
|
75 |
}
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=yehuda@m
|
|
4 |
Tags: postman smtp, postman, smtp, email, mail, mailer, email log, oauth2, gmail, google apps, hotmail, yahoo, mandrill api, sendgrid api, elastic email, office365, mailgun
|
5 |
Requires at least: 3.9
|
6 |
Tested up to: 4.9.4
|
7 |
-
Stable tag: 1.8.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -284,6 +284,9 @@ To avoid being flagged as spam, you need to prove your email isn't forged. On a
|
|
284 |
|
285 |
== Changelog ==
|
286 |
|
|
|
|
|
|
|
287 |
= 1.8.1 - 2017-12-24
|
288 |
* New: Sendgrid API & Client Version 6
|
289 |
* New: Add email log 'send to' column
|
4 |
Tags: postman smtp, postman, smtp, email, mail, mailer, email log, oauth2, gmail, google apps, hotmail, yahoo, mandrill api, sendgrid api, elastic email, office365, mailgun
|
5 |
Requires at least: 3.9
|
6 |
Tested up to: 4.9.4
|
7 |
+
Stable tag: 1.8.2
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
284 |
|
285 |
== Changelog ==
|
286 |
|
287 |
+
= 1.8.2 - 2017-12-24
|
288 |
+
* Fix: SendGrid API Call Structure
|
289 |
+
|
290 |
= 1.8.1 - 2017-12-24
|
291 |
* New: Sendgrid API & Client Version 6
|
292 |
* New: Add email log 'send to' column
|