From 28d34dd9508df38143995ba971b31ef08e3326b8 Mon Sep 17 00:00:00 2001 From: James McDonald Date: Mon, 23 Dec 2019 16:21:38 +1100 Subject: [PATCH 1/3] Add ability to use h: headers --- src/Mailer/Transport/MailgunTransport.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Mailer/Transport/MailgunTransport.php b/src/Mailer/Transport/MailgunTransport.php index 9323ead..0ebee4f 100644 --- a/src/Mailer/Transport/MailgunTransport.php +++ b/src/Mailer/Transport/MailgunTransport.php @@ -7,7 +7,7 @@ * For full copyright and license information, please see the LICENSE.md * Redistributions of files must retain the above copyright notice. * - * @copyright Copyright (c) Narendra Vaghela (http://www.narendravaghela.com) + * @copyright 2020 Copyright (c) Narendra Vaghela (http://www.narendravaghela.com) * @license https://opensource.org/licenses/mit-license.php MIT License * @link https://github.com/narendravaghela/cakephp-mailgun * @since 1.0.0 @@ -57,8 +57,14 @@ class MailgunTransport extends AbstractTransport 'skip-verification', ]; + /** + * @var string + */ protected $_mailgunHeaderPrefix = 'X-Mailgun'; + /** + * @var array + */ protected $_mailgunHeaders = [ 'X-Mailgun-Tag' => 'tag', 'X-Mailgun-Dkim' => 'dkim', @@ -429,6 +435,9 @@ protected function _processHeaders(Email $email) $this->_formData->add("{$this->_optionPrefix}$var", $value); } } + if (0 === strpos($header, $this->_customHeaderPrefix) && !empty($value)) { + $this->_formData->add($header, $value); + } } } -} +} \ No newline at end of file From 9485a3c9fe756bda68eacea47efb0f08aba62c0b Mon Sep 17 00:00:00 2001 From: James McDonald Date: Mon, 23 Dec 2019 20:25:03 +1100 Subject: [PATCH 2/3] change to elseif so $header check runs once only --- src/Mailer/Transport/MailgunTransport.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Mailer/Transport/MailgunTransport.php b/src/Mailer/Transport/MailgunTransport.php index 0ebee4f..8bd7f51 100644 --- a/src/Mailer/Transport/MailgunTransport.php +++ b/src/Mailer/Transport/MailgunTransport.php @@ -434,8 +434,7 @@ protected function _processHeaders(Email $email) $var = $this->_mailgunHeaders[$header]; $this->_formData->add("{$this->_optionPrefix}$var", $value); } - } - if (0 === strpos($header, $this->_customHeaderPrefix) && !empty($value)) { + } elseif (0 === strpos($header, $this->_customHeaderPrefix) && !empty($value)) { $this->_formData->add($header, $value); } } From 935d18ac50bff4fc9e2149e20f1f1434667f9ccc Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 23 Dec 2019 09:32:35 +0000 Subject: [PATCH 3/3] Fixing style errors. --- src/Mailer/Transport/MailgunTransport.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mailer/Transport/MailgunTransport.php b/src/Mailer/Transport/MailgunTransport.php index 8bd7f51..6d3fda5 100644 --- a/src/Mailer/Transport/MailgunTransport.php +++ b/src/Mailer/Transport/MailgunTransport.php @@ -439,4 +439,4 @@ protected function _processHeaders(Email $email) } } } -} \ No newline at end of file +}