-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Mailer] DataPart#setContentId
requires @
#54162
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
Comments
If having |
I don't know what the spec is, to be honest. I may try to prepare a PR for either of the possible solutions. Let me know. |
I found this RFC 2392. It refers to So provided the RFCs are in use, it would seem the CID has to contain at least one Also, I suggest adding the info to the restriction for further clarification. Something in the line of "This restriction is in place for CID to adhere to RFC 2392 which requires URL-encoded RFC 822 addr-spec string." If someone stumbles upon the restriction in code they can refer to the documents for reasoning. |
The issue I faced when I opened this issue on github was, that I was passing a parsed content id from a mail Ive received. The Mail was properly displayed in a bunch of Mail clients (well I guess these have to deal with a lot of stuff) and thus I was expecting that there is no requirement for an @ That is why I suggested to have a For now, we are adding an Imho thats not a good solution but works for now (we are forwarding parsed mails and thats why we have to deal with it). So it would help if at least the strictness could be toggled off so that there is no need to replace HTML body as in our case. |
See #57295 for a better error message. |
So if it was agreed that the |
PR welcome to improve the documentation |
Understood. Thanks for the feedback. |
This PR was merged into the 7.2 branch. Discussion ---------- [Mime] Tweak an exception to be more descriptive | Q | A | ------------- | --- | Branch? | 7.2 | Bug fix? | no | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Issues | Fix #54162 <!-- prefix each issue number with "Fix #", no need to create an issue if none exists, explain below instead --> | License | MIT Commits ------- b5cacc9 [Mime] Tweak an exception to be more descriptive
Dox PR here: symfony/symfony-docs#19946 |
…ocumentation (dakujem) This PR was merged into the 6.4 branch. Discussion ---------- [Mailer] Fixed and clarified custom Content-ID feature documentation > Addresses [symfony/symfony #54162](symfony/symfony#54162) The documentation is incorrect, as it shows calls to `DataPart::setContentId` with strings that are rejected by [the method's implementation](https://github.com/symfony/symfony/blob/7.2/src/Symfony/Component/Mime/Part/DataPart.php#L66), because they do not contain a required `@` character.  I also added a sentence clarifying that the actual Content-ID value will be ramdom-generated by Symfony when not using a custom Content-ID. This feature has been added in `v6.3` (according to the documentation) and the documentation is incorrect throughout versions `6.3`, `6.4`, `7.0`, `7.1` and `7.2`. I'm not sure how to distribute this PR to all other branches - should I create separate PRs for each? Commits ------- 468a9ac [Mailer] Fixed and clarified custom Content-ID feature documentation
Symfony version(s) affected
6.2.0 - 7.0.5
Description
We are using
symfony/mailer
to partially forward messages with attachments as they were received i.e. from outlook, gmail, etc. accounts.Some mail clients seem to create attachments with content-ids not containing
@
which led to issues when forwarding those messages viasymfony/mailer
.We do now have to generate that
@
-Part plus replacing thenon-@
-content id within HTML bodies. Tho it does work to manually search/replacecid:<contentIdWithout@>
, this feels kinda weird.From what I can read from the RFC (mentioned in the PR referenced below), there is no requirement for an
@
and since there are clients out there which do generate mails without@
which are properly displayed in other mail clients, etc. I wonder if this "validation" is really necessary.Refs: #46962
How to reproduce
Extracted from the
DataPartTest#testSetContentIdInvalid
of #46962Possible Solution
Maybe, allow passing a
strict
boolean flag via__construct
which allows projects as ours to bypass this kind of validation.I have no idea why it had to be implemented in the first place but as I am aware of the BC contract symfony is pushing, I'd be fine with opt-in for non-strict validation.
Additional Context
The text was updated successfully, but these errors were encountered: