Skip to content

Commit 705e32a

Browse files
Merge branch '4.4' into 5.0
* 4.4: (26 commits) [HttpClient] NativeHttpClient should not send >1.1 protocol version [HttpClient] fix support for non-blocking resource streams [Mailer] Make sure you can pass custom headers to Mailgun [Mailer] Remove line breaks in email attachment content Update links to documentation [Validator] Add the missing translations for the Arabic (ar) locale ensure to expect no validation for the right reasons [Security-Guard] fixed 35203 missing name tag in param docblock [HttpClient] fix casting responses to PHP streams [PhpUnitBridge] Add test case for @expectedDeprecation annotation [PhpUnitBridge][SymfonyTestsListenerTrait] Remove $testsWithWarnings stack [Mailer] Fix addresses management in Sendgrid API payload [Mailer][MailchimpBridge] Fix missing attachments when sending via Mandrill API [Mailer][MailchimpBridge] Fix incorrect sender address when sender has name [HttpClient] fix capturing SSL certificates with NativeHttpClient Update year in license files [TwigBridge][Form] Added missing help messages in form themes Update year in license files Update year in license files fix version when "anonymous: lazy" was introduced ...
2 parents 488ea8e + c877c84 commit 705e32a

23 files changed

+327
-33
lines changed

Amazon/LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2019 Fabien Potencier
1+
Copyright (c) 2019-2020 Fabien Potencier
22

33
Permission is hereby granted, free of charge, to any person obtaining a copy
44
of this software and associated documentation files (the "Software"), to deal

Google/LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2019 Fabien Potencier
1+
Copyright (c) 2019-2020 Fabien Potencier
22

33
Permission is hereby granted, free of charge, to any person obtaining a copy
44
of this software and associated documentation files (the "Software"), to deal

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2019 Fabien Potencier
1+
Copyright (c) 2019-2020 Fabien Potencier
22

33
Permission is hereby granted, free of charge, to any person obtaining a copy
44
of this software and associated documentation files (the "Software"), to deal

Mailchimp/LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2019 Fabien Potencier
1+
Copyright (c) 2019-2020 Fabien Potencier
22

33
Permission is hereby granted, free of charge, to any person obtaining a copy
44
of this software and associated documentation files (the "Software"), to deal

Mailchimp/Tests/Transport/MandrillApiTransportTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\Mailer\Bridge\Mailchimp\Transport\MandrillApiTransport;
16+
use Symfony\Component\Mailer\Envelope;
17+
use Symfony\Component\Mime\Address;
18+
use Symfony\Component\Mime\Email;
1619

1720
class MandrillApiTransportTest extends TestCase
1821
{
@@ -41,4 +44,21 @@ public function getTransportData()
4144
],
4245
];
4346
}
47+
48+
public function testCustomHeader()
49+
{
50+
$email = new Email();
51+
$email->getHeaders()->addTextHeader('foo', 'bar');
52+
$envelope = new Envelope(new Address('[email protected]'), [new Address('[email protected]')]);
53+
54+
$transport = new MandrillApiTransport('ACCESS_KEY');
55+
$method = new \ReflectionMethod(MandrillApiTransport::class, 'getPayload');
56+
$method->setAccessible(true);
57+
$payload = $method->invoke($transport, $email, $envelope);
58+
59+
$this->assertArrayHasKey('message', $payload);
60+
$this->assertArrayHasKey('headers', $payload['message']);
61+
$this->assertCount(1, $payload['message']['headers']);
62+
$this->assertEquals('foo: bar', $payload['message']['headers'][0]);
63+
}
4464
}

Mailchimp/Transport/MandrillApiTransport.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,14 @@ private function getPayload(Email $email, Envelope $envelope): array
9494
'type' => $headers->get('Content-Type')->getBody(),
9595
];
9696

97+
if ($name = $headers->getHeaderParameter('Content-Disposition', 'name')) {
98+
$att['name'] = $name;
99+
}
100+
97101
if ('inline' === $disposition) {
98-
$payload['images'][] = $att;
102+
$payload['message']['images'][] = $att;
99103
} else {
100-
$payload['attachments'][] = $att;
104+
$payload['message']['attachments'][] = $att;
101105
}
102106
}
103107

@@ -107,7 +111,7 @@ private function getPayload(Email $email, Envelope $envelope): array
107111
continue;
108112
}
109113

110-
$payload['message']['headers'][] = $name.': '.$header->toString();
114+
$payload['message']['headers'][] = $name.': '.$header->getBodyAsString();
111115
}
112116

113117
return $payload;

Mailgun/LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2019 Fabien Potencier
1+
Copyright (c) 2019-2020 Fabien Potencier
22

33
Permission is hereby granted, free of charge, to any person obtaining a copy
44
of this software and associated documentation files (the "Software"), to deal

Mailgun/Tests/Transport/MailgunApiTransportTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\Mailer\Bridge\Mailgun\Transport\MailgunApiTransport;
16+
use Symfony\Component\Mailer\Envelope;
17+
use Symfony\Component\Mime\Address;
18+
use Symfony\Component\Mime\Email;
1619

1720
class MailgunApiTransportTest extends TestCase
1821
{
@@ -45,4 +48,20 @@ public function getTransportData()
4548
],
4649
];
4750
}
51+
52+
public function testCustomHeader()
53+
{
54+
$json = json_encode(['foo' => 'bar']);
55+
$email = new Email();
56+
$email->getHeaders()->addTextHeader('X-Mailgun-Variables', $json);
57+
$envelope = new Envelope(new Address('[email protected]'), [new Address('[email protected]')]);
58+
59+
$transport = new MailgunApiTransport('ACCESS_KEY', 'DOMAIN');
60+
$method = new \ReflectionMethod(MailgunApiTransport::class, 'getPayload');
61+
$method->setAccessible(true);
62+
$payload = $method->invoke($transport, $email, $envelope);
63+
64+
$this->assertArrayHasKey('h:x-mailgun-variables', $payload);
65+
$this->assertEquals($json, $payload['h:x-mailgun-variables']);
66+
}
4867
}

Mailgun/Transport/MailgunApiTransport.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ private function getPayload(Email $email, Envelope $envelope): array
114114
continue;
115115
}
116116

117-
$payload['h:'.$name] = $header->toString();
117+
$payload['h:'.$name] = $header->getBodyAsString();
118118
}
119119

120120
return $payload;

MailgunApiTransport.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ private function getPayload(Email $email, Envelope $envelope): array
114114
continue;
115115
}
116116

117-
$payload['h:'.$name] = $header->toString();
117+
$payload['h:'.$name] = $header->getBodyAsString();
118118
}
119119

120120
return $payload;

MailgunApiTransportTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\Mailer\Bridge\Mailgun\Transport\MailgunApiTransport;
16+
use Symfony\Component\Mailer\Envelope;
17+
use Symfony\Component\Mime\Address;
18+
use Symfony\Component\Mime\Email;
1619

1720
class MailgunApiTransportTest extends TestCase
1821
{
@@ -45,4 +48,20 @@ public function getTransportData()
4548
],
4649
];
4750
}
51+
52+
public function testCustomHeader()
53+
{
54+
$json = json_encode(['foo' => 'bar']);
55+
$email = new Email();
56+
$email->getHeaders()->addTextHeader('X-Mailgun-Variables', $json);
57+
$envelope = new Envelope(new Address('[email protected]'), [new Address('[email protected]')]);
58+
59+
$transport = new MailgunApiTransport('ACCESS_KEY', 'DOMAIN');
60+
$method = new \ReflectionMethod(MailgunApiTransport::class, 'getPayload');
61+
$method->setAccessible(true);
62+
$payload = $method->invoke($transport, $email, $envelope);
63+
64+
$this->assertArrayHasKey('h:x-mailgun-variables', $payload);
65+
$this->assertEquals($json, $payload['h:x-mailgun-variables']);
66+
}
4867
}

MandrillApiTransport.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,14 @@ private function getPayload(Email $email, Envelope $envelope): array
9494
'type' => $headers->get('Content-Type')->getBody(),
9595
];
9696

97+
if ($name = $headers->getHeaderParameter('Content-Disposition', 'name')) {
98+
$att['name'] = $name;
99+
}
100+
97101
if ('inline' === $disposition) {
98-
$payload['images'][] = $att;
102+
$payload['message']['images'][] = $att;
99103
} else {
100-
$payload['attachments'][] = $att;
104+
$payload['message']['attachments'][] = $att;
101105
}
102106
}
103107

@@ -107,7 +111,7 @@ private function getPayload(Email $email, Envelope $envelope): array
107111
continue;
108112
}
109113

110-
$payload['message']['headers'][] = $name.': '.$header->toString();
114+
$payload['message']['headers'][] = $name.': '.$header->getBodyAsString();
111115
}
112116

113117
return $payload;

MandrillApiTransportTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\Mailer\Bridge\Mailchimp\Transport\MandrillApiTransport;
16+
use Symfony\Component\Mailer\Envelope;
17+
use Symfony\Component\Mime\Address;
18+
use Symfony\Component\Mime\Email;
1619

1720
class MandrillApiTransportTest extends TestCase
1821
{
@@ -41,4 +44,21 @@ public function getTransportData()
4144
],
4245
];
4346
}
47+
48+
public function testCustomHeader()
49+
{
50+
$email = new Email();
51+
$email->getHeaders()->addTextHeader('foo', 'bar');
52+
$envelope = new Envelope(new Address('[email protected]'), [new Address('[email protected]')]);
53+
54+
$transport = new MandrillApiTransport('ACCESS_KEY');
55+
$method = new \ReflectionMethod(MandrillApiTransport::class, 'getPayload');
56+
$method->setAccessible(true);
57+
$payload = $method->invoke($transport, $email, $envelope);
58+
59+
$this->assertArrayHasKey('message', $payload);
60+
$this->assertArrayHasKey('headers', $payload['message']);
61+
$this->assertCount(1, $payload['message']['headers']);
62+
$this->assertEquals('foo: bar', $payload['message']['headers'][0]);
63+
}
4464
}

Postmark/LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2019 Fabien Potencier
1+
Copyright (c) 2019-2020 Fabien Potencier
22

33
Permission is hereby granted, free of charge, to any person obtaining a copy
44
of this software and associated documentation files (the "Software"), to deal

Postmark/Tests/Transport/PostmarkApiTransportTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\Mailer\Bridge\Postmark\Transport\PostmarkApiTransport;
16+
use Symfony\Component\Mailer\Envelope;
17+
use Symfony\Component\Mime\Address;
18+
use Symfony\Component\Mime\Email;
1619

1720
class PostmarkApiTransportTest extends TestCase
1821
{
@@ -41,4 +44,21 @@ public function getTransportData()
4144
],
4245
];
4346
}
47+
48+
public function testCustomHeader()
49+
{
50+
$email = new Email();
51+
$email->getHeaders()->addTextHeader('foo', 'bar');
52+
$envelope = new Envelope(new Address('[email protected]'), [new Address('[email protected]')]);
53+
54+
$transport = new PostmarkApiTransport('ACCESS_KEY');
55+
$method = new \ReflectionMethod(PostmarkApiTransport::class, 'getPayload');
56+
$method->setAccessible(true);
57+
$payload = $method->invoke($transport, $email, $envelope);
58+
59+
$this->assertArrayHasKey('Headers', $payload);
60+
$this->assertCount(1, $payload['Headers']);
61+
62+
$this->assertEquals(['Name' => 'foo', 'Value' => 'bar'], $payload['Headers'][0]);
63+
}
4464
}

Postmark/Transport/PostmarkApiTransport.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ private function getPayload(Email $email, Envelope $envelope): array
8484

8585
$payload['Headers'][] = [
8686
'Name' => $name,
87-
'Value' => $header->toString(),
87+
'Value' => $header->getBodyAsString(),
8888
];
8989
}
9090

PostmarkApiTransport.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ private function getPayload(Email $email, Envelope $envelope): array
8484

8585
$payload['Headers'][] = [
8686
'Name' => $name,
87-
'Value' => $header->toString(),
87+
'Value' => $header->getBodyAsString(),
8888
];
8989
}
9090

PostmarkApiTransportTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\Mailer\Bridge\Postmark\Transport\PostmarkApiTransport;
16+
use Symfony\Component\Mailer\Envelope;
17+
use Symfony\Component\Mime\Address;
18+
use Symfony\Component\Mime\Email;
1619

1720
class PostmarkApiTransportTest extends TestCase
1821
{
@@ -41,4 +44,21 @@ public function getTransportData()
4144
],
4245
];
4346
}
47+
48+
public function testCustomHeader()
49+
{
50+
$email = new Email();
51+
$email->getHeaders()->addTextHeader('foo', 'bar');
52+
$envelope = new Envelope(new Address('[email protected]'), [new Address('[email protected]')]);
53+
54+
$transport = new PostmarkApiTransport('ACCESS_KEY');
55+
$method = new \ReflectionMethod(PostmarkApiTransport::class, 'getPayload');
56+
$method->setAccessible(true);
57+
$payload = $method->invoke($transport, $email, $envelope);
58+
59+
$this->assertArrayHasKey('Headers', $payload);
60+
$this->assertCount(1, $payload['Headers']);
61+
62+
$this->assertEquals(['Name' => 'foo', 'Value' => 'bar'], $payload['Headers'][0]);
63+
}
4464
}

Sendgrid/LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2019 Fabien Potencier
1+
Copyright (c) 2019-2020 Fabien Potencier
22

33
Permission is hereby granted, free of charge, to any person obtaining a copy
44
of this software and associated documentation files (the "Software"), to deal

0 commit comments

Comments
 (0)