Search code examples
javajakarta-mail

Is it possible to get who is the email service provider of the particular mail using JavaMail API


I'm using JavaMail jar to read the mail from my Gmail inbox. I am able to read the content of the mail. But I want to know who is the email service provider of the mail.

Actually, we can find those details in 'Show Original' of the Gmail. I want to get that using JavaMail API. Is there any way for getting the mail provider?

Please help me.

Please see the screenshot


Solution

  • The Received message headers are accessible from JavaMail with the getHeader method. But note that they're not 100% reliable, and they don't always follow any sort of strict syntax so be careful how much you depend on them.