You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Move header filtering from MimeMessageParser to EmailConverter, thereby enabling access to all parsed headers when using MimeMessageParser directly
#487
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.
Hi, first of all, thank you for this great library.
I'm opening this issue to ask if there are any possibility to tweak the ignored headers list used by the MimeMessageParser.
I'm asking this because I'm in a situation where I need to parse an .eml file and retrieve all the "Received" headers.
After a bit of debugging I found the HEADERS_TO_IGNORE list in MimeMessageParser.java which contains all the ignored headers.
Is there any possibility to customize this behaviour?
Thanks in advance!
The text was updated successfully, but these errors were encountered:
I finally got around to looking into your use case. The problem with this is, when you build an Email instance, you can do all sorts of stuff with it, not least of all use it to send an email somewhere. In the underlying framework Jakarta/Angus Mail, this is done via headers. These headers are produced by Simple Java Mail to guarantee a correctly configured MimeMessage that behaves accordingly. Not only that, the underlying framework adds more headers that would interfere with this process if they were already included during sending.
Now, if we parse an email file, took these generated headers and kept them, then you have a 'tainted' Email instance. This would be great for simply reading emails, but we can't guarantee a correcting behaviour anymore when sending such emails. So that's why I'm reluctant to allowing in more headers from a source email.
However, having said that, I may be able to offer different solution. I could move the ignoring of the headers out of the MimeMessageParser and further into the Simple Java Mail library where this class is used. Then, you could use the MimeMessageParser directly -which is already public- and then use that instead to parse your email file.
Hi, thanks for the detailed explanation.
I think it can work for my use case.
At the moment I'm using the MimeMessage.getAllHeaders() to achieve the same result, but if your library could provide the parsed headers would be certainly better.
Also, I noticed that in my first message I have not specified why I need the Received headers.
What I'm trying to do is to retrieve the sent and the received date of an email.
Correct if I'm wrong, but without accessing the Received headers, I can only get the sent date using Email.getSentDate().
bbottema
changed the title
Ignored headers customization in MimeMessageParser
Move header filtering from MimeMessageParser to EmailConverter, thereby enabling access to all parsed headers when using MimeMessageParser directly
Jan 18, 2024
Hi, first of all, thank you for this great library.
I'm opening this issue to ask if there are any possibility to tweak the ignored headers list used by the
MimeMessageParser
.I'm asking this because I'm in a situation where I need to parse an .eml file and retrieve all the "Received" headers.
After a bit of debugging I found the
HEADERS_TO_IGNORE
list inMimeMessageParser.java
which contains all the ignored headers.Is there any possibility to customize this behaviour?
Thanks in advance!
The text was updated successfully, but these errors were encountered: