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

Commit 4f766ba

Browse filesBrowse files
committed
[Mailgun Mailer] fixed issue when using html body
1 parent a25c2af commit 4f766ba
Copy full SHA for 4f766ba

File tree

Expand file treeCollapse file tree

2 files changed

+14
-1
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+14
-1
lines changed

‎src/Symfony/Component/Mailer/Bridge/Mailgun/Http/Api/MailgunTransport.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Mailer/Bridge/Mailgun/Http/Api/MailgunTransport.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ private function getPayload(Email $email, SmtpEnvelope $envelope): array
6868
{
6969
$headers = $email->getHeaders();
7070
$html = $email->getHtmlBody();
71-
if (null !== $html) {
71+
if (null !== $html && \is_resource($html)) {
7272
if (stream_get_meta_data($html)['seekable'] ?? false) {
7373
rewind($html);
7474
}

‎src/Symfony/Component/Mailer/Tests/TransportTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Mailer/Tests/TransportTest.php
+13Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,19 @@ public function testFromDsnMailgun()
168168
$transport = Transport::fromDsn('api://'.urlencode('u$er').':'.urlencode('pa$s').'@mailgun?region=us', $dispatcher, $client, $logger);
169169
$transport->send($message);
170170

171+
$message = (new Email())->from('me@me.com')->to('you@you.com')->subject('hello')->html('test');
172+
$client = $this->createMock(HttpClientInterface::class);
173+
$client->expects($this->once())->method('request')->with('POST', 'https://api.mailgun.net/v3/pa%24s/messages')->willReturn($response);
174+
$transport = Transport::fromDsn('api://'.urlencode('u$er').':'.urlencode('pa$s').'@mailgun?region=us', $dispatcher, $client, $logger);
175+
$transport->send($message);
176+
177+
$stream = fopen('data://text/plain,'.$message->getTextBody(), 'r');
178+
$message->html($stream);
179+
$client = $this->createMock(HttpClientInterface::class);
180+
$client->expects($this->once())->method('request')->with('POST', 'https://api.mailgun.net/v3/pa%24s/messages')->willReturn($response);
181+
$transport = Transport::fromDsn('api://'.urlencode('u$er').':'.urlencode('pa$s').'@mailgun?region=us', $dispatcher, $client, $logger);
182+
$transport->send($message);
183+
171184
$this->expectException(LogicException::class);
172185
Transport::fromDsn('foo://mailgun');
173186
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.