How to read e-mails in a local directory using Java? - jakarta-mail

I would like to create a java program that would get only the body/message of the mail, the mails are in .eml format and the mails are placed locally in my machine. The problem is when I try to look for ways to do this I'm still lead to use the Folder class which requires an active mail server. Now, my question is, is there any way I can extract the message part of an e-mail using the Javamail API without the need to connect to a server? Because doing the extraction of the message part of an e-mail without including its headers is nearly impossible with filestream.
Thanks for the help.
Cheers!

You can use a "local store provider" for JavaMail, but perhaps the simplest approach for you is to just use the MimeMessage that takes an InputStream. Give it a (buffered) FileInputStream and it will parse the message for you.

Related

Where is the Email stored until it was send (Symfony Mailer)

When sending an Email in Symphony Mailer there needs to be a worker consumes it, before it is send. Therefore the files have to be stored in some place, but I cant find out where. I searched in my project, but i couldn't find anything in any directory.
This Information could prove useful for finding and debugging Emails, when you do not receive them and if you want to know if they are still saved.
It depends on the Mailer's spool and path configuration.
See https://symfony.com/doc/4.4/reference/configuration/swiftmailer.html#spool
Also try php bin/console debug:config framework mailer

File with the extension of ".ehi" content is not readable

Has anyone encountered a file that has an extension of ".ehi" before?
If I open it using Wordpad, its contents are not readable strings.
What app should I use in order to open this file type?
What is an EHI file?
Config file used by HTTP Injector, an Android app used to modify
requests and access blocked websites behind firewall with SSH support
and proxy server; contains settings that configure HTTP Injector,
which includes server login credentials and security/locking
information.
Based on this information, it makes sense that the data isn't stored in plain text. The credentials are likely encrypted or otherwise stored in an obfuscated format to help prevent unauthorized access.
Source: https://fileinfo.com/extension/ehi

How to get important flag from Java Mail client

Is there a way to get whether a mail is marked as important or not from Java Mail API.? I'm using a Gmail account to connect. Thanks in advance.
Different mailers use different ways to indicate that a message is "important". Some use an X-Priority header. Others use an Importance header. I don't know offhand what Gmail uses, but look at the raw headers of a message and you should be able to figure it out. Then use the JavaMail getHeader method to access that header.

How to store mail info for mail client

I'm working on a side project right now for an email client. I'm using a library to handle the retrieval of the messages from the server. However, I have a question on caching.
I don't want to fetch the entire list of headers everytime I load the client. Ideally, what I'd like to do is cache them and then update the list with what is on the server.
What's the best way to go about this? Should I store all the header information (including the server's message ID #) in a database, load the headers from that DB. Then as a background task sync up with the server...
Or is there a better way?
Look at the webmail sample of this open source project that use local caching:
http://mailsystem.codeplex.com/
If I remember well, he used a combination of local RFC822 plain text email storing with the message id as the filename and an index file with high level data.
Maybe the message itself where zipped to save disc space.
That's just a sample for the library, so don't expect code art there, but that's a start.

smtp sends headers as content

I'm using remote smtp server(from my host company) and send
email from local computer.(google app development server)
But instead of getting nice emails
i get emails that contain headers as if it ware content of email
What can do to change it?
My guess is that you have a newline (\r\n or Carriage Return -Line Feed) in your subject. And, your mailing program doesn't strip newlines in the subject.
If you put a newline in the subject, and your app doesn't remove it, you just moved all following headers down to the body.
Send the email according to the SMTP RFC: https://www.rfc-editor.org/rfc/rfc5321
Getting the headers in the content sounds like you sent them twice or did separate the headers from the content in a way your mail client does not understand.
Check you don't have something wrapping what you send in another layer of email.
Perhaps look at the current (real/outer) headers to see if that gives any clues.
Can you show us your code, please? You don't say which App Engine runtime you're using; I'll assume Python. The App Engine mail API doesn't let you directly set message headers. There's a list of attributes you can set here.

Resources