Subject: Q: Can sending-filters add/modify headers?

From: Russtopia <[email-masked]>
Date: Fri, 18 Feb 2005 20:29:19 -0700

Hi all,

Hopefully this isn't an FAQ -- searched the archive and didn't find 
anything, so..

I'm trying to write a send filter for Pine to add the X-Hashcash:
header. Basic idea is to call an external script which inserts this
header, with a stamp generated by hashcash, when sending messages:

From: [email-masked]
To: [email-masked]
<other pine standard headers>
X-Hashcash: <stamp value generated by sending-filter>

[body]

I've added the "sending-filter" hook to my script:

sending-filters=/usr/local/bin/hashcash4pine -i _TMPFILE_ _INCLUDEALLHDRS_

.. and it re-writes the message inserting the X-Hashcash: header.

However, it appears that Pine doesn't actually *use* the headers
output to the filter, it just gives them to the scripts as read-only 
info (that is, the filter gets copies of the headers and Pine does not 
read these modified headers back in and use them for the outgoing message).

Looking at the Pine source seems to confirm this; filter_message_text() 
in send.c parses the internal METAENV *header to send the header info to 
the filter, but doesn't expect that the filter may have changed them, so 
it sends its original list followed by a blank line. Thus my X-Hashcash: 
header appears as part of the message body.

I also tried removing _INCLUDEALLHDRS_ and _TMPFILE_ from my filter, 
thus working with stdin/stdout, and writing X-Hashcash: <stamp> as the 
very first line of the body; but because Pine insists on writing a blank 
line after its own header items in METAENV, X-Hashcash: still appears as 
part of the body instead of the headers.

Is there some other hook I've missed that lets one dynamically generate 
extra headers for outgoing mail? Or is there a way for a filter to add a 
header immediately after the ones in the METAENV list?

I know I can add the X-Hashcash: field to the Rich Header list, but that 
doesn't let me call an external program and actually fill in the stamp 
value.

Thanks,
-Russ Magee