-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[Mailer] Mailjet - Allow using Reply-To with Mailjet API #38179
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
Conversation
OskarStark
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, but I would prefer an exception instead of the logged warning. 👍🏻
| } | ||
| if ($emails = $email->getReplyTo()) { | ||
| if (1 < $length = \count($emails)) { | ||
| $this->getLogger()->warning(sprintf('Mailjet\'s API only supports one Reply-To email, %d given. The first one will be used.', $length)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would throw an exception instead. I think that having more than one Reply-To address is an edge case and if it happens, it's important to make sure that the dev understands that it is not supported. I understand the interoperability argument, but I think it's better here to fail when something is not supported.
Can you also make the same change in Sendgrid to be consistent?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fabpot wouldn't adding this change to Sengrid break backward-compatibility as some apps may rely on the current behaviour of the transport ?
Also, if transports are not fully interoperable, should we document it and maybe list transport specificities ?
069aa02 to
c8ed052
Compare
|
Changed from a logged warning to an exception and adapted tests. |
|
Thank you @t-richard. |
c8ed052 to
1ff3e29
Compare
…t-richard)
This PR was squashed before being merged into the 5.2-dev branch.
Discussion
----------
[Mailer] Mailjet - Allow using Reply-To with Mailjet API
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | none
| License | MIT
| Doc PR | none
Using this bridge I got an error from Mailjet API given below and this PR fixes this issue.
<details>
<summary>Error from Mailjet</summary>
```json
{
"Messages": [
{
"Status": "error",
"Errors": [
{
"ErrorIdentifier": "xxxx",
"ErrorCode": "send-0011",
"StatusCode": 400,
"ErrorMessage": "Header cannot be customized using the \"Headers\" collection. Please use the dedicated property to set this header.",
"ErrorRelatedTo": [
"Headers[\"Reply-To\"]"
]
}
]
}
]
}
```
</details>
As detailed in [the Mailjet API doc](https://dev.mailjet.com/email/reference/send-emails/index.html#v3_1_post_send), `ReplyTo` is a single email address whereas the `Symfony\Mime\Email` class allows for several emails in `ReplyTo`.
I implemented the [same logic as the Sendgrid bridge](https://github.com/symfony/symfony/blob/0f5ac5dc8f944a719e7d71729c0a63e1cfc9c6b5/src/Symfony/Component/Mailer/Bridge/Sendgrid/Transport/SendgridApiTransport.php#L96) but added logging (I first thought about throwing an exception but this would reduce transport interchangeability).
Note : `Reply-To` is not listed in the ["Forbidden headers" section of Mailjet's documentation](https://dev.mailjet.com/email/guides/send-api-v31/#add-email-headers) but the API response is clear about the expected input.
Commits
-------
1ff3e29 [Mailer] Mailjet - Allow using Reply-To with Mailjet API
Using this bridge I got an error from Mailjet API given below and this PR fixes this issue.
Error from Mailjet
```json { "Messages": [ { "Status": "error", "Errors": [ { "ErrorIdentifier": "xxxx", "ErrorCode": "send-0011", "StatusCode": 400, "ErrorMessage": "Header cannot be customized using the \"Headers\" collection. Please use the dedicated property to set this header.", "ErrorRelatedTo": [ "Headers[\"Reply-To\"]" ] } ] } ] } ```As detailed in the Mailjet API doc,
ReplyTois a single email address whereas theSymfony\Mime\Emailclass allows for several emails inReplyTo.I implemented the same logic as the Sendgrid bridge but added logging (I first thought about throwing an exception but this would reduce transport interchangeability).
Note :
Reply-Tois not listed in the "Forbidden headers" section of Mailjet's documentation but the API response is clear about the expected input.