Skip to content

Postmark API mailer transport should exclude the Date header #60254

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
rtek opened this issue Apr 22, 2025 · 0 comments
Closed

Postmark API mailer transport should exclude the Date header #60254

rtek opened this issue Apr 22, 2025 · 0 comments

Comments

@rtek
Copy link
Contributor

rtek commented Apr 22, 2025

Symfony version(s) affected

6.4.19

Description

When sending an email using the Postmark API transport, with a Date header set, postmark rejects the message, and the transport throws this exception:

Fatal error: Uncaught Symfony\Component\Mailer\Exception\HttpTransportException: 
Unable to send an email: Header 'Date' not allowed. (code 300). in
/vendor/symfony/postmark-mailer/Transport/PostmarkApiTransport.php:72

How to reproduce

$transport = new \Symfony\Component\Mailer\Bridge\Postmark\Transport\PostmarkApiTransport('***');
$email = new \Symfony\Component\Mime\Email();

$email->text(date('c'))
    ->to('foo@localhost')
    ->from('bar@localhost')
    ->date(new \DateTimeImmutable());

$transport->send($email);

//PHP Fatal error:  Uncaught Symfony\Component\Mailer\Exception\HttpTransportException: Unable to send an email: Header 'Date' not allowed. (code 300). in vendor/symfon/postmark-
mailer/Transpor/PostmarkApiTransport.php:72

Possible Solution

Fix is to add 'date' to this exclusion list: https://github.com/symfony/postmark-mailer/blob/7.2/Transport/PostmarkApiTransport.php#L113

Workaround is to remove the date header from the email before sending it.

Additional Context

No response

@rtek rtek added the Bug label Apr 22, 2025
@xabbuh xabbuh added the Mailer label Apr 23, 2025
fabpot added a commit that referenced this issue Apr 30, 2025
…ansport (xabbuh)

This PR was merged into the 6.4 branch.

Discussion
----------

[Mailer][Postmark] drop the `Date` header using the API transport

| Q             | A
| ------------- | ---
| Branch?       | 6.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Issues        | Fix #60254
| License       | MIT

Commits
-------

2db187a drop the Date header using the Postmark API transport
@fabpot fabpot closed this as completed Apr 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants