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?