Skip to content

Commit 03b34da

Browse files
committed
[Mailer] Fix Message ID for Postmark SMTP
1 parent 57c3956 commit 03b34da

File tree

6 files changed

+30
-4
lines changed

6 files changed

+30
-4
lines changed

Mailgun/Transport/MailgunApiTransport.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ protected function doSendApi(SentMessage $sentMessage, Email $email, Envelope $e
6868
throw new HttpTransportException(sprintf('Unable to send an email: %s (code %s).', $result['message'], $response->getStatusCode()), $response);
6969
}
7070

71-
throw new HttpTransportException(sprintf('Unable to send an email: %s (code %s).', $result, $response->getStatusCode()), $response);
71+
throw new HttpTransportException(sprintf('Unable to send an email: %s (code %s).', $response->getContent(false), $response->getStatusCode()), $response);
7272
}
7373

7474
$sentMessage->setMessageId($result['id']);

Mailgun/Transport/MailgunHttpTransport.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ protected function doSendHttp(SentMessage $message): ResponseInterface
7070
throw new HttpTransportException(sprintf('Unable to send an email: %s (code %s).', $result['message'], $response->getStatusCode()), $response);
7171
}
7272

73-
throw new HttpTransportException(sprintf('Unable to send an email: %s (code %s).', $result, $response->getStatusCode()), $response);
73+
throw new HttpTransportException(sprintf('Unable to send an email: %s (code %s).', $response->getContent(false), $response->getStatusCode()), $response);
7474
}
7575

7676
$message->setMessageId($result['id']);

MailgunApiTransport.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ protected function doSendApi(SentMessage $sentMessage, Email $email, Envelope $e
6868
throw new HttpTransportException(sprintf('Unable to send an email: %s (code %s).', $result['message'], $response->getStatusCode()), $response);
6969
}
7070

71-
throw new HttpTransportException(sprintf('Unable to send an email: %s (code %s).', $result, $response->getStatusCode()), $response);
71+
throw new HttpTransportException(sprintf('Unable to send an email: %s (code %s).', $response->getContent(false), $response->getStatusCode()), $response);
7272
}
7373

7474
$sentMessage->setMessageId($result['id']);

MailgunHttpTransport.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ protected function doSendHttp(SentMessage $message): ResponseInterface
7070
throw new HttpTransportException(sprintf('Unable to send an email: %s (code %s).', $result['message'], $response->getStatusCode()), $response);
7171
}
7272

73-
throw new HttpTransportException(sprintf('Unable to send an email: %s (code %s).', $result, $response->getStatusCode()), $response);
73+
throw new HttpTransportException(sprintf('Unable to send an email: %s (code %s).', $response->getContent(false), $response->getStatusCode()), $response);
7474
}
7575

7676
$message->setMessageId($result['id']);

Postmark/Transport/PostmarkSmtpTransport.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@
1212
namespace Symfony\Component\Mailer\Bridge\Postmark\Transport;
1313

1414
use Psr\Log\LoggerInterface;
15+
use Symfony\Component\Mailer\Envelope;
16+
use Symfony\Component\Mailer\SentMessage;
1517
use Symfony\Component\Mailer\Transport\Smtp\EsmtpTransport;
18+
use Symfony\Component\Mime\Message;
19+
use Symfony\Component\Mime\RawMessage;
1620
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
1721

1822
/**
@@ -27,4 +31,13 @@ public function __construct(string $id, EventDispatcherInterface $dispatcher = n
2731
$this->setUsername($id);
2832
$this->setPassword($id);
2933
}
34+
35+
public function send(RawMessage $message, Envelope $envelope = null): ?SentMessage
36+
{
37+
if ($message instanceof Message) {
38+
$message->getHeaders()->addTextHeader('X-PM-KeepID', 'true');
39+
}
40+
41+
return parent::send($message, $envelope);
42+
}
3043
}

PostmarkSmtpTransport.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@
1212
namespace Symfony\Component\Mailer\Bridge\Postmark\Transport;
1313

1414
use Psr\Log\LoggerInterface;
15+
use Symfony\Component\Mailer\Envelope;
16+
use Symfony\Component\Mailer\SentMessage;
1517
use Symfony\Component\Mailer\Transport\Smtp\EsmtpTransport;
18+
use Symfony\Component\Mime\Message;
19+
use Symfony\Component\Mime\RawMessage;
1620
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
1721

1822
/**
@@ -27,4 +31,13 @@ public function __construct(string $id, EventDispatcherInterface $dispatcher = n
2731
$this->setUsername($id);
2832
$this->setPassword($id);
2933
}
34+
35+
public function send(RawMessage $message, Envelope $envelope = null): ?SentMessage
36+
{
37+
if ($message instanceof Message) {
38+
$message->getHeaders()->addTextHeader('X-PM-KeepID', 'true');
39+
}
40+
41+
return parent::send($message, $envelope);
42+
}
3043
}

0 commit comments

Comments
 (0)