-
Notifications
You must be signed in to change notification settings - Fork 323
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
Support for MIME headers when using NewEmailFromReader #140
base: master
Are you sure you want to change the base?
Support for MIME headers when using NewEmailFromReader #140
Conversation
Hello @tarmo-randma Having support for Content-ID would be awesome ❤️ Some emails just have
What do you think ? |
@leucos I agree, this could go both ways: the library could actually skip adding filename when |
I will try to take another pass at the PR. Have been busy lately. I am interested of handling the ContentID correctly for my own project as well. |
The build is failing but I think this is due to the missing go.mod file not my changes? Could you please take look? As for the changes I did in relation to content-id:
|
I believe the build error is due to using Go 1.16 instead of 1.15? The change seems to have been really recent - this PR from just 2 days ago still uses 1.15: See Go 1.16 release notes: https://golang.org/doc/go1.16. I think the first part about modules applies:
Might be something else but for me this looks like the prime suspect. |
@tarmo-randma yes you're probably right. PR #143 passes but the author added a |
How would you like to handle this? Are you going to merge that go.mod? Proper module support would be great but I am not sure how adding it would impact compatibility for everyone. Maybe it should include a major version bump? I am ofcourse OK with either solution - go-mod or a build flag to change the new default behavior |
I think this works now. Should also allow accepting other PR-s |
This PR resolves #139 - Missing MIME headers with NewEmailFromReader.
The issue once again:
In the latest master version (943e75f) when e-mails are created with NewEmailFromReader and they contain attachments, the attachments will have empty MIME headers. This is due to commit b84218f on Dec 30, 2020 which resolved a different issue. The MIME headers were never covered by a Unit test, so this was not picked up.
The old removed implementation however was also buggy as it set the Content-Id header of the attachment always to the file name. This is incorrect behavior as Content-Id can have a different value and should be read directly from the MIME header.
This PR:
Resolves the issue by attaching the original MIME headers also to the Attachment object. The parsed values will thus be available separately as struct fields but the raw values will be available as well.
In order to maintain API compatibility a new variation of the Attach() function was also created named AttachWithHeaders() which takes an extra argument. It would have been possible to add the headers directly in the NewEmailFromReader() function and skip this new function but I thought it would be better to make it explicit in the API as well that the original function does not add headers. If this new function is too much clutter, I will be happy to amend the PR and add the headers directly in the NewEmailFromReader() function.
Tests have been created to cover the Content-Id header of attachments