Description
This is my first bug report / contribution to Symfony (or any other open source project), so I hope I did it correctly. Otherwise, just let me know.
Symfony version(s) affected: 4.4 - 5.2
Description
The Postmark API expects multiple addresses to be split by a comma. When the name of an Address contains a comma, this comma is not escaped. So the Postmark API thinks it's getting multiple addresses, while it's actually one address with a comma in the name.
How to reproduce
See https://github.com/scvandenbraak/symfony-postmark-mailer-comma-bug for example code and README.
When you run the simple example without a Postmark Server token, you'll see the output below, showing the comma has not been escaped.
string(24) "My, Name <me@domain.tld>"
You will get the error if you run a real example with Postmark:
In PostmarkApiTransport.php line 59:
Unable to send an email: Error parsing 'To': Illegal email address 'My'. It must contain the '@' symbol. (code 300).
Possible Solution
Use quotes around the name. This can be fixed in several places:
- Method
getPayload
inTransport/PostmarkApiTransport.php
ofsymfony/postmark-mailer
. - Method
stringifyAddresses
inTransport/AbstractTransport.php
ofsymfony/mailer
. - Method
toString
inAddress.php
ofsymfony/mime
.
I would guess option 3 is the best, but that depends on which other components rely on this method and it the extra quotes could brake anything. I can also make a PR when I know where it should be fixed.
Additional context
See API description "Multiple addresses are comma separated." at "To" on https://postmarkapp.com/developer/api/email-api#send-a-single-email.