Powershell script to read and timespan  SMTP headers, if anyone is interested.
Copy the headers to file hdr.txt in the same directory as the script, and run 
it.



$hdr_txt = gc ./hdr.txt
$from_hdr = $hdr_txt | select-string "^From\:\s.+$"
$rec_block = $hdr_txt[0..$($from_hdr.linenumber -2)]
$rec_lines = $rec_block | select-string "^Received\:\sfrom"

$sent_hdr = $hdr_txt | select-string "^Date\:\s.+$"
$sent_hdr.line -match "^Date\:\s(.+)$" > $nul
$sent_ts = [datetime]$matches[1]

$rec_hdr_regex = 
[regex]"^Received\:\sfrom\s(.+?)\sby\s(.+?)\swith\s(.+?)\;\s(.+?\d\d\:\d\d\:\d\d\s[+|-]\d{4})"

foreach ($rec_line in $rec_lines[1..$($rec_lines.count 
-1)]){$rec_block[$rec_line.linenumber -1] = "~" + $rec_line.line}
$rec_hdrs  = $([string]$rec_block).split("~")

$i = $rec_hdrs.count -1
$last_ts = $sent_ts
Write-host "`nMessage sent $($sent_ts)`n"

while ($i -ge 0) {

$rec_hdrs[$i] -match $rec_hdr_regex > $nul

$rec_ts = [datetime]$matches[4]
$latency = $rec_ts - $last_ts
$last_ts = $rec_ts
write-host "latency is $($latency.totalseconds) seconds`n"
$matches[1]
$i--
}
Write-host "Message received $($last_ts)"
write-host "Total time is $($($last_ts - $sent_ts).seconds) seconds. `n"

**************************************************************************************************
Note: 
The information contained in this message may be privileged and confidential 
and 
protected from disclosure.  If the reader of this message is not the intended  
recipient, or an employee or agent responsible for delivering this message to  
the intended recipient, you are hereby notified that any dissemination,   
distribution or copying of this communication is strictly prohibited. If you  
have received this communication in error, please notify us immediately by  
replying to the message and deleting it from your computer. 
**************************************************************************************************

~ Ninja Email Security with Cloudmark Spam Engine Gets Image Spam ~
~             http://www.sunbeltsoftware.com/Ninja                ~

Reply via email to