procmail
[Top] [All Lists]

Folding E-mail Headers

2006-04-18 18:12:10
Hi there,

Have tried to figure this out from reading the man page for "fold", searching 
through the archives of this list, and a general Web search, but haven't had 
any success. Almost all of the hits when searching for "fold" relate to 
redirecting messages to pagers, and that's not what I'm trying to do here.

I would like to use Procmail to (among other things) insert an "X-" header with 
a relatively long string of text (including the header name it's 575 
characters) into messages passing through a recipe. I've had no problems doing 
this, but I'd like to fold this long line to comply with RFC 2822, which 
suggests folding after 78 characters.

I have this in my recipe, which inserts the header without folding it:

:0 fh w
| formail -i "X-My-Header: Long string of text here."

I'm guessing that I need to pipe this into fold somehow, but I'm not "getting" 
how to do it. The fold syntax, if the header I want to insert is in a file, 
would be:

fold -s -w78 x_my_header.txt

I could assign this to a variable in the recipe, which would make things 
easier, like this:

x_my_header = 'X-My-Header: Long string of text here.'

But trying:

fold -s -w78 $x_my_header

causes fold to choke. Plus, of course, I still haven't figured out where 
exactly this should go in the Procmail recipe relative to formail, so I'm not 
getting anywhere.

Any pointers in the right direction with respect to getting fold to fold the 
long header and then getting formail to take the output from fold and insert 
the header would be much appreciated. Thanks very much.


Craig



____________________________________________________________
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>