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 f8b0bfd

Browse filesBrowse files
committed
bug #32131 [Mailgun Mailer] fixed issue when using html body (alOneh)
This PR was merged into the 4.3 branch. Discussion ---------- [Mailgun Mailer] fixed issue when using html body | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | I tested the `symfony/mailgun-mailer` and get an issue when using the `api` scheme with a templated email cause we try to manipulate a stream whereas the `Symfony\Component\Mime\Email::getHtmlBody()` could return also a string (in my case it is one). The issue : ``` stream_get_meta_data() expects parameter 1 to be resource, string given ``` Commits ------- afbefe1 [Mailgun Mailer] fixed issue when using html body
2 parents 0c9b3c0 + afbefe1 commit f8b0bfd
Copy full SHA for f8b0bfd

File tree

2 files changed

+14
-1
lines changed
Filter options

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
@@ -175,6 +175,19 @@ public function testFromDsnMailgun()
175175
$transport = Transport::fromDsn('api://'.urlencode('u$er').':'.urlencode('pa$s').'@mailgun?region=us', $dispatcher, $client, $logger);
176176
$transport->send($message);
177177

178+
$message = (new Email())->from('me@me.com')->to('you@you.com')->subject('hello')->html('test');
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+
184+
$stream = fopen('data://text/plain,'.$message->getTextBody(), 'r');
185+
$message = (new Email())->from('me@me.com')->to('you@you.com')->subject('hello')->html($stream);
186+
$client = $this->createMock(HttpClientInterface::class);
187+
$client->expects($this->once())->method('request')->with('POST', 'https://api.mailgun.net/v3/pa%24s/messages')->willReturn($response);
188+
$transport = Transport::fromDsn('api://'.urlencode('u$er').':'.urlencode('pa$s').'@mailgun?region=us', $dispatcher, $client, $logger);
189+
$transport->send($message);
190+
178191
$this->expectException(LogicException::class);
179192
Transport::fromDsn('foo://mailgun');
180193
}

0 commit comments

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