Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Mailer] [Mailgun] Fix outlook sender #51773

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ public function testCustomHeader()
$deliveryTime = (new \DateTimeImmutable('2020-03-20 13:01:00'))->format(\DateTimeInterface::RFC2822);

$email = new Email();
$envelope = new Envelope(new Address('alice@system.com'), [new Address('bob@system.com')]);
$email->getHeaders()->addTextHeader('h:sender', $envelope->getSender()->toString());
$email->getHeaders()->addTextHeader('h:X-Mailgun-Variables', $json);
$email->getHeaders()->addTextHeader('h:foo', 'foo-value');
$email->getHeaders()->addTextHeader('t:text', 'text-value');
Expand All @@ -69,7 +71,6 @@ public function testCustomHeader()
$email->getHeaders()->addTextHeader('template', 'template-value');
$email->getHeaders()->addTextHeader('recipient-variables', 'recipient-variables-value');
$email->getHeaders()->addTextHeader('amp-html', 'amp-html-value');
$envelope = new Envelope(new Address('alice@system.com'), [new Address('bob@system.com')]);

$transport = new MailgunApiTransport('ACCESS_KEY', 'DOMAIN');
$method = new \ReflectionMethod(MailgunApiTransport::class, 'getPayload');
Expand All @@ -78,6 +79,8 @@ public function testCustomHeader()
$this->assertArrayHasKey('h:X-Mailgun-Variables', $payload);
$this->assertEquals($json, $payload['h:X-Mailgun-Variables']);

$this->assertArrayHasKey('h:sender', $payload);
$this->assertEquals($envelope->getSender()->toString(), $payload['h:sender']);
$this->assertArrayHasKey('h:foo', $payload);
$this->assertEquals('foo-value', $payload['h:foo']);
$this->assertArrayHasKey('t:text', $payload);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ public function testSend()
$this->assertStringContainsString('Subject: Hello!', $content);
$this->assertStringContainsString('To: Saif Eddin <saif.gmati@symfony.com>', $content);
$this->assertStringContainsString('From: Fabien <fabpot@symfony.com>', $content);
$this->assertStringContainsString('Sender: Senior Fabien Eddin <fabpot@symfony.com>', $content);
$this->assertStringContainsString('h:sender: "Senior Fabien Eddin" <fabpot@symfony.com>', $content);
$this->assertStringContainsString('Hello There!', $content);

return new MockResponse(json_encode(['id' => 'foobar']), [
Expand All @@ -79,11 +81,17 @@ public function testSend()
$transport->setPort(8984);

$mail = new Email();
$toAddress = new Address('saif.gmati@symfony.com', 'Saif Eddin');
$fromAddress = new Address('fabpot@symfony.com', 'Fabien');
$senderAddress = new Address('fabpot@symfony.com', 'Senior Fabien Eddin');
$mail->subject('Hello!')
->to(new Address('saif.gmati@symfony.com', 'Saif Eddin'))
->from(new Address('fabpot@symfony.com', 'Fabien'))
->to($toAddress)
->from($fromAddress)
->sender($senderAddress)
->text('Hello There!');

$mail->getHeaders()->addHeader('h:sender', $mail->getSender()->toString());

$message = $transport->send($mail);

$this->assertSame('foobar', $message->getMessageId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ protected function doSendApi(SentMessage $sentMessage, Email $email, Envelope $e
private function getPayload(Email $email, Envelope $envelope): array
{
$headers = $email->getHeaders();
$headers->addHeader('h:sender', $envelope->getSender()->toString());
$html = $email->getHtmlBody();
if (null !== $html && \is_resource($html)) {
if (stream_get_meta_data($html)['seekable'] ?? false) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public function __toString(): string
protected function doSendHttp(SentMessage $message): ResponseInterface
{
$body = new FormDataPart([
'h:sender' => $message->getEnvelope()->getSender()->toString(),
'to' => implode(',', $this->stringifyAddresses($message->getEnvelope()->getRecipients())),
'message' => new DataPart($message->toString(), 'message.mime'),
]);
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.