[Mailgun Mailer] fixed issue when using html body
This commit is contained in:
parent
a25c2af559
commit
afbefe131b
@ -68,7 +68,7 @@ class MailgunTransport extends AbstractApiTransport
|
||||
{
|
||||
$headers = $email->getHeaders();
|
||||
$html = $email->getHtmlBody();
|
||||
if (null !== $html) {
|
||||
if (null !== $html && \is_resource($html)) {
|
||||
if (stream_get_meta_data($html)['seekable'] ?? false) {
|
||||
rewind($html);
|
||||
}
|
||||
|
@ -168,6 +168,19 @@ class TransportTest extends TestCase
|
||||
$transport = Transport::fromDsn('api://'.urlencode('u$er').':'.urlencode('pa$s').'@mailgun?region=us', $dispatcher, $client, $logger);
|
||||
$transport->send($message);
|
||||
|
||||
$message = (new Email())->from('me@me.com')->to('you@you.com')->subject('hello')->html('test');
|
||||
$client = $this->createMock(HttpClientInterface::class);
|
||||
$client->expects($this->once())->method('request')->with('POST', 'https://api.mailgun.net/v3/pa%24s/messages')->willReturn($response);
|
||||
$transport = Transport::fromDsn('api://'.urlencode('u$er').':'.urlencode('pa$s').'@mailgun?region=us', $dispatcher, $client, $logger);
|
||||
$transport->send($message);
|
||||
|
||||
$stream = fopen('data://text/plain,'.$message->getTextBody(), 'r');
|
||||
$message = (new Email())->from('me@me.com')->to('you@you.com')->subject('hello')->html($stream);
|
||||
$client = $this->createMock(HttpClientInterface::class);
|
||||
$client->expects($this->once())->method('request')->with('POST', 'https://api.mailgun.net/v3/pa%24s/messages')->willReturn($response);
|
||||
$transport = Transport::fromDsn('api://'.urlencode('u$er').':'.urlencode('pa$s').'@mailgun?region=us', $dispatcher, $client, $logger);
|
||||
$transport->send($message);
|
||||
|
||||
$this->expectException(LogicException::class);
|
||||
Transport::fromDsn('foo://mailgun');
|
||||
}
|
||||
|
Reference in New Issue
Block a user