summaryrefslogtreecommitdiff
path: root/Postman
diff options
context:
space:
mode:
authorYehuda Hassine <yehuda@myinbox.in>2019-05-12 23:19:58 +0300
committerYehuda Hassine <yehuda@myinbox.in>2019-05-12 23:19:58 +0300
commit038dc3839338d5384d263f2488a6f67adf99ec7c (patch)
tree9f4f9d4e109aac6f30b19418e410474b2cc71f28 /Postman
parent75e5f6e319d5d36f3076fe2eb449bb089b8ce3da (diff)
downloadPost-SMTP-038dc3839338d5384d263f2488a6f67adf99ec7c.zip
Dummy PHPMailer delivery + Message Id handler
Diffstat (limited to 'Postman')
-rw-r--r--Postman/Phpmailer/PostsmtpMailer.php13
-rw-r--r--Postman/Postman.php3
-rw-r--r--Postman/PostmanWpMail.php9
3 files changed, 13 insertions, 12 deletions
diff --git a/Postman/Phpmailer/PostsmtpMailer.php b/Postman/Phpmailer/PostsmtpMailer.php
index 82527d2..f3e0479 100644
--- a/Postman/Phpmailer/PostsmtpMailer.php
+++ b/Postman/Phpmailer/PostsmtpMailer.php
@@ -33,13 +33,11 @@ class PostsmtpMailer extends PHPMailer {
$senderEmail = $this->options->getMessageSenderEmail();
$senderName = $this->options->getMessageSenderName();
- $this->addCustomHeader('X-Mailer', 'PostSMTP/' . POST_SMTP_VER );
-
// create a PostmanMessage instance
$message = $postmanWpMail->createNewMessage();
$message->setFrom( $senderEmail, $senderName );
- $message->addHeaders( $this->getCustomHeaders() );
+ $message->addHeaders( $this->getHeaders() );
$message->setBodyTextPart( $this->AltBody );
$message->setBodyHtmlPart( $this->Body );
$message->setBody( $this->Body );
@@ -75,6 +73,15 @@ class PostsmtpMailer extends PHPMailer {
}
+ private function getHeaders() {
+ $headers = array();
+ foreach ( $this->getCustomHeaders() as $header ) {
+ $headers[] = "{$header[0]}: {$header[1]}";
+ }
+
+ return $headers;
+ }
+
public function postman_wp_mail_result() {
$result = [
'time' => '',
diff --git a/Postman/Postman.php b/Postman/Postman.php
index 2956d44..c3b0177 100644
--- a/Postman/Postman.php
+++ b/Postman/Postman.php
@@ -97,8 +97,9 @@ class Postman {
$this->logger->trace( 'SMTP Mailer: ' . PostmanOptions::getInstance()->getSmtpMailer() );
+ $mailer = PostmanOptions::getInstance()->getSmtpMailer();
if ( PostmanOptions::getInstance()->getTransportType() == 'smtp' &&
- PostmanOptions::getInstance()->getSmtpMailer() !== 'phpmailer') {
+ $mailer && $mailer !== 'phpmailer') {
// bind to wp_mail - this has to happen before the "init" action
// this design allows other plugins to register a Postman transport and call bind()
diff --git a/Postman/PostmanWpMail.php b/Postman/PostmanWpMail.php
index 3d1f8f5..66b3279 100644
--- a/Postman/PostmanWpMail.php
+++ b/Postman/PostmanWpMail.php
@@ -42,10 +42,6 @@ if ( ! class_exists( 'PostmanWpMail' ) ) {
// initialize for sending
$this->init();
- if ( ! is_array( $headers ) ) {
- $headers = explode( "\n", str_replace( "\r\n", "\n", $headers ) );
- }
-
// build the message
$postmanMessage = $this->processWpMailCall( $to, $subject, $message, $headers, $attachments );
@@ -65,11 +61,8 @@ if ( ! class_exists( 'PostmanWpMail' ) ) {
* @return PostmanMessage
*/
private function apply_default_headers( $message ) {
- $headers = $message->getHeaders();
$headers[] = 'Message-ID: ' . $this->createMessageId();
$message->addHeaders($headers);
-
- return $message;
}
/**
@@ -182,7 +175,7 @@ if ( ! class_exists( 'PostmanWpMail' ) ) {
*/
public function sendMessage( PostmanMessage $message, PostmanEmailLog $log ) {
- $message = $this->apply_default_headers( $message );
+ $this->apply_default_headers( $message );
// get the Options and AuthToken
$options = PostmanOptions::getInstance();