Skip to content

Commit

Permalink
bug #36888 [Mailer] Fix mandrill raw http request setting from email/…
Browse files Browse the repository at this point in the history
…name (JohJohan)

This PR was merged into the 4.4 branch.

Discussion
----------

[Mailer] Fix mandrill raw http request setting from email/name

| Q             | A
| ------------- | ---
| Branch?       | 4.4, 5.0, 5.1
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #36879
| License       | MIT
| Doc PR        | None

As describe in symfony/symfony#36879 there is a bug in sending raw http request to mandrill it will not set from email/name correct.

As you can see i make sure to set `from_email` and `from_name` correct now and changed the unit test to check correct you can see the doc that the format is correct https://mandrillapp.com/api/docs/messages.curl.html#method-send-raw

Commits
-------

6128dd0b75 ticket_36879 - Fix mandrill raw http request setting from email/name
  • Loading branch information
fabpot committed Jul 15, 2020
2 parents 6a7df30 + d845ac5 commit 2d6663b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Tests/Transport/MandrillHttpTransportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ public function testSend()
$body = json_decode($options['body'], true);
$message = $body['raw_message'];
$this->assertSame('KEY', $body['key']);
$this->assertSame('Fabien', $body['from_name']);
$this->assertSame('fabpot@symfony.com', $body['from_email']);
$this->assertSame('saif.gmati@symfony.com', $body['to'][0]);
$this->assertSame('Fabien <fabpot@symfony.com>', $body['from_email']);

$this->assertStringContainsString('Subject: Hello!', $message);
$this->assertStringContainsString('To: Saif Eddin <saif.gmati@symfony.com>', $message);
Expand Down
3 changes: 2 additions & 1 deletion Transport/MandrillHttpTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ protected function doSendHttp(SentMessage $message): ResponseInterface
'to' => array_map(function (Address $recipient): string {
return $recipient->getAddress();
}, $envelope->getRecipients()),
'from_email' => $envelope->getSender()->toString(),
'from_email' => $envelope->getSender()->getAddress(),
'from_name' => $envelope->getSender()->getName(),
'raw_message' => $message->toString(),
],
]);
Expand Down

0 comments on commit 2d6663b

Please sign in to comment.