bbottema / simple-java-mail

Simple API, Complex Emails (Jakarta Mail smtp wrapper)
http://www.simplejavamail.org
Apache License 2.0
1.22k stars 265 forks source link

Make the use of 'filename' and 'name' as additional parameters within the content-type header optional #541

Open sebastian-schmitt opened 3 weeks ago

sebastian-schmitt commented 3 weeks ago

When adding an attachment, the Content-Type header of the corresponding mime-part gets the 'filename' and 'name' of the attachment appended as additional parameters (see link below).

Our remote party is pretty picky about this header and wants us to remove these extra parameters from this header. I could not find a good way to do that - this is why I wish I could opt-out from this behavior:

https://github.com/bbottema/simple-java-mail/blob/cb2f7b2b0dac9c7a7bda1d209c40a21550bf4738/modules/simple-java-mail/src/main/java/org/simplejavamail/converter/internal/mimemessage/MimeMessageHelper.java#L264-L267

sebastian-schmitt commented 3 weeks ago

alternatively I was looking for some hook to modify the intermediate MimeMessage at some point between being built and being sent. (maybe the CustomMailer?)

sebastian-schmitt commented 3 weeks ago

after digging deeper into our problem, I found that only one of those parameters (namely the "filename") causes the problems at the remote side: They expect the "name" parameter within the Content-Type header and the "filename" parameter within the Content-Disposition header. So basically, it's the line 265 only (see above) which I try to disable. (for now we forked the repository to do this manipulation by hand, but it would be great to have some kind of tool to access and modify the resulting MimeMessage in more detail)

bbottema commented 3 days ago

I'm trying to remember why I left it in the Content-Type to begin with. Legacy? Backwards compatibility? I'm trying to figure out what I might break by simply removing it.