From 6836dfcb7d1618578607798d3fb74c40c4617af2 Mon Sep 17 00:00:00 2001 From: Mark Wilde Date: Thu, 30 Jul 2015 17:15:16 +0100 Subject: [PATCH 1/2] Added getMessage method to access Swift_Message --- net/mail/transport/adapter/Swift.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/net/mail/transport/adapter/Swift.php b/net/mail/transport/adapter/Swift.php index 9f436f7..a3cd8c4 100644 --- a/net/mail/transport/adapter/Swift.php +++ b/net/mail/transport/adapter/Swift.php @@ -49,6 +49,8 @@ class Swift extends \li3_mailer\net\mail\Transport { ) ); + protected $_message; + /** * Message property names for translating a `li3_mailer\net\mail\Message` * to `Swift_Message`. @@ -89,8 +91,16 @@ class Swift extends \li3_mailer\net\mail\Transport { */ public function deliver($message, array $options = array()) { $transport = $this->_transport($options); - $message = $this->_message($message); - return $transport->send($message); + $this->_message = $this->_message($message); + return $transport->send($this->_message); + } + + /** + * Allows read access to the SiwftMailer message object after it's + * been delivered. + */ + public function getMessage() { + return $this->_message; } /** From 229cb480bba2ca5cb98021e639090cdb608a9ab1 Mon Sep 17 00:00:00 2001 From: Mark Wilde Date: Thu, 30 Jul 2015 19:11:10 +0100 Subject: [PATCH 2/2] Updated to support a getMessageId to fix a bug Needed to store the message ID separately as Swiftmailer changes the ID on the message object after send. --- net/mail/transport/adapter/Swift.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/net/mail/transport/adapter/Swift.php b/net/mail/transport/adapter/Swift.php index a3cd8c4..6f812d3 100644 --- a/net/mail/transport/adapter/Swift.php +++ b/net/mail/transport/adapter/Swift.php @@ -51,6 +51,8 @@ class Swift extends \li3_mailer\net\mail\Transport { protected $_message; + protected $_messageId; + /** * Message property names for translating a `li3_mailer\net\mail\Message` * to `Swift_Message`. @@ -91,10 +93,21 @@ class Swift extends \li3_mailer\net\mail\Transport { */ public function deliver($message, array $options = array()) { $transport = $this->_transport($options); + $this->_message = $this->_message($message); + $this->_messageId = $this->_message->getId(); + return $transport->send($this->_message); } + /** + * Allows read access to the message id after it's + * been delivered. + */ + public function getMessageId() { + return $this->_messageId; + } + /** * Allows read access to the SiwftMailer message object after it's * been delivered.