procmail
[Top] [All Lists]

RE: Converting from MH to mbox?

2004-02-09 14:35:30

From: David W. Tamkin
Sent: Monday, February 09, 2004 12:44 PM
[...]

If you have GNU date or another date(1) that supports the -d switch,
perhaps you can extract the timestamp of the original delivery from the
topmost Received: header and have GNU date rewrite it in the proper form
for a From_ line.

Something along these lines:

#!/bin/sh
# for testing - first arg is the message filename
msg="$1"
# Topmost Received: line
rcvd=`formail -u "Received:" -zcx Received < $msg`
# Extract the date part, *mailer dependent*
rcvd_date=`echo "$rcvd" | sed -e 's/^.*;//;s/^[
  *]//;s/[       ]*$//'`
# Put into to From_ format
# example: Mon Feb  9 12:15:08 2004
from_date=`date --date="$rcvd_date" +"%a %b %e %R:%S %Y"`
# Add the from line with this date
formail -a "Date: $from_date" < $msg



_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail