<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Perl on The Gnu Pit</title><link>https://gnupit.net/perl/</link><description>Recent content in Perl on The Gnu Pit</description><generator>Hugo</generator><language>en-US</language><lastBuildDate>Wed, 07 Nov 2012 19:51:24 -0500</lastBuildDate><atom:link href="https://gnupit.net/perl/index.xml" rel="self" type="application/rss+xml"/><item><title>Script: Parse Mail Headers</title><link>https://gnupit.net/posts/parse_mail_headers/</link><pubDate>Wed, 07 Nov 2012 19:51:24 -0500</pubDate><guid>https://gnupit.net/posts/parse_mail_headers/</guid><description>&lt;p&gt;Here&amp;rsquo;s a perl script I put together that uses Email::Simple to extract the headers from a message. See link below.&lt;/p&gt;
&lt;p&gt;I&amp;rsquo;m using it to examine spam. It parses all the headers, with a focus on the Received headers. It should be easy to alter it to examine any header you want. As it is currently written, it:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;finds all the Received headers&lt;/li&gt;
&lt;li&gt;finds the first Received header that was added to the mail (presumably the header added by the first MTA that received it)&lt;/li&gt;
&lt;li&gt;extracts the IP from that header&lt;/li&gt;
&lt;li&gt;does an rDNS lookup&lt;/li&gt;
&lt;li&gt;if there&amp;rsquo;s a hostname, it looks up the nameservers for the base domain.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;By &amp;ldquo;base domain&amp;rdquo; I mean that if the rDNS returns a hostname like &amp;ldquo;1234.my.example.domain.com&amp;rdquo;, the base domain would be &amp;ldquo;domain.com&amp;rdquo;.&lt;/p&gt;</description></item></channel></rss>