diff --git a/.gitignore b/.gitignore
index bc959c5..55b86aa 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,5 @@
/composer.lock
/phpunit.xml
/vendor
+/.phpunit.result.cache
+/clover.xml
diff --git a/src/Mailer/Transport/MailgunTransport.php b/src/Mailer/Transport/MailgunTransport.php
index 7a0eac6..3efe58c 100644
--- a/src/Mailer/Transport/MailgunTransport.php
+++ b/src/Mailer/Transport/MailgunTransport.php
@@ -333,6 +333,10 @@ protected function _prepareEmailAddresses(Email $email)
$this->_formData->add('from', sprintf("%s <%s>", key($from), key($from)));
}
+ foreach ($email->getSender() as $senderEmail => $senderName) {
+ $this->_formData->add('h:Sender', sprintf("%s <%s>", $senderName, $senderEmail));
+ }
+
foreach ($email->getTo() as $toEmail => $toName) {
$this->_formData->add('to', sprintf("%s <%s>", $toName, $toEmail));
}
diff --git a/tests/TestCase/Mailer/Transport/MailgunTransportTest.php b/tests/TestCase/Mailer/Transport/MailgunTransportTest.php
index 5b49a4f..1dd9215 100644
--- a/tests/TestCase/Mailer/Transport/MailgunTransportTest.php
+++ b/tests/TestCase/Mailer/Transport/MailgunTransportTest.php
@@ -86,6 +86,7 @@ public function testAdditionalEmailAddresses()
->addCC(['ccbar@example.com', 'ccjohn@example.com' => 'John'])
->addBcc(['bccbar@example.com', 'bccjohn@example.com' => 'John'])
->setReplyTo(['replyto@example.com' => 'John'])
+ ->setSender(['sender@example.com' => 'John'])
->setEmailFormat('both')
->setSubject('Email from CakePHP Mailgun plugin')
->send('Hello there,
This is an email from CakePHP Mailgun Email plugin.');
@@ -101,6 +102,7 @@ public function testAdditionalEmailAddresses()
$this->assertTextContains('Content-Disposition: form-data; name="cc"', $reqDataString);
$this->assertTextContains('Content-Disposition: form-data; name="bcc"', $reqDataString);
$this->assertTextContains('Content-Disposition: form-data; name="h:Reply-To"', $reqDataString);
+ $this->assertTextContains('Content-Disposition: form-data; name="h:Sender"', $reqDataString);
$this->assertTextContains('from@example.com ', $reqDataString);
$this->assertTextContains('to@example.com ', $reqDataString);
$this->assertTextContains('ccbar@example.com ', $reqDataString);
@@ -108,6 +110,7 @@ public function testAdditionalEmailAddresses()
$this->assertTextContains('bccbar@example.com ', $reqDataString);
$this->assertTextContains('John ', $reqDataString);
$this->assertTextContains('John ', $reqDataString);
+ $this->assertTextContains('John ', $reqDataString);
}
public function testCustomHeaders()