procmail
[Top] [All Lists]

adding a missing Date: header

2008-10-03 14:56:34

For obscure reasons, the Dilbert.com daily strip email does not include
a Date: header.  (It does include Delivery-date:, but I haven't tracked
down where that is being added.)  When I sort the folder by date, mh-e
complains about unreadable dates, so I decided to add the date to any
message missing that header in procmail.  I didn't want to calculate the
date string unless the Date: header was missing, so this is what I came
up with:

# Generate any missing Date: header
:0
* ! ^Date:
{
  :0
  { DATE_=`ruby -e "require 'time'; print Time.now.rfc2822"`}

  :0 fhw:
  | formail -a "Date: ${DATE_}" -a "X-Date: added date header"
}


While this does add a Date: header to any message without it, it also
ends up being evaluated as a delivering recipe.  I've fiddled with it in
different ways and I haven't been able to make it into a non-delivering
recipe.  Could someone fix this so it doesn't deliver?

I really thought this would be a FAQ, but I couldn't find an example of
calculating a value and inserting it into a missing header.

Thanks a lot!

Lester
____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

<Prev in Thread] Current Thread [Next in Thread>