2

I am looking for an RFC 2821 standard parser in Java that can parse the Received: line in Email Headers properly. There have been a lot of inconsistencies in the Received line format and tracing back to the sender source is becoming difficult.

For Example:-

Received: from [52.27.245.142] ([52.27.245.142:36568] helo=w8emlsvc103agp1.w8.jungle.tech-mailer_process) by ab.mta2vsmtp.cc.prd.sparkpost (envelope-from <survey-noreply@mr.surveymonkeyuser.com>) (ecelerity 4.3.1.83676 r(Core:4.3.1.37)) with ESMTPSA (cipher=AES-256-GCM) id 76/B7-08965-7F6B81F5; Wed, 22 Jul 2020 22:00:23 +0000

or

Received: from mail04.xxx.yyy.com (mail04.xxx.yyy.com. [15x.5x.2x.1x])
    by mx.google.com with ESMTPS id b11si1303166wme.160.2020.08.10.20.29.10
    for <xxx@gmail.com>
    (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128);
    Mon, 10 Aug 2020 20:29:10 -0700 (PDT)

Looking to perform an SPF validation, so I need senders originating IP address, which is straight forward but for validating if this is the actual senders originating address I would need to trace the path and understand all the headers in the message so parsing the received lines is mandatory.

Any suggestions?

user207421
  • 305,947
  • 44
  • 307
  • 483
  • Use JavaMail. It already does it. [tag:apache] has nothing to do with it. Off topic. – user207421 Sep 03 '20 at 05:58
  • I am using javax.mail library already to parse the mail and got the Enumeration
    and stuff. However, I am looking for a parser to parse the "Received:" line to fetch the information like "from (name) ', "from (address)", "from (hostname)", "by (name)", "by (hostname)" etc.
    – Shaik Rizwan Sep 03 '20 at 22:37
  • You should have mentioned that in your question and tags. – user207421 Sep 04 '20 at 05:19

0 Answers0