In comp.mail.misc, Chris Davies <
ch...@roaima.co.uk> wrote:
> Nomen Nescio <
nob...@dizum.com> wrote:
> > I want to add a custom header (e.g. "X-My-Custom-Header: my data") to
> > a message sent using the "mail" command.
> > I'm having a hard time seeing how this is done.
The "mail" program could be a lot of things. Traditional "mail" might
be able to do it via crazy ~ commands, but "mailx" or "nail" has
likely fixed those issues (they can be used for security exploits in
some situations).
> If you really need a custom header, the truly generic solution is to
> create enough of the headers to make a message that can be fed directly
> to /usr/lib/sendmail:
> FROM=
chris-...@roaima.co.uk
> TO=doc...@tardis.galifrey.kasterborous.piscescetus.glx
> (
...
Someone has already written a nice shell script that does this for
you. It's called "Rnmail" and it ships with trn. Just run it with
no arguments and it will prompt for To: and Subject: then dump you
in $EDITOR with fully modifiable headers.
> ) | /usr/lib/sendmail -f "$FROM" "$TO"
Although, as shipped Rnmail does not use -f to set envelope "From ".
It does use -t to read the recipients from the message, however.
I've hacked my version to add -f in, if I set From: in the message.
I use formail (from the procmail package) to extract the bare address,
since envelope "From " does not include a name field.
Here's what the "sendmail" state of the case statement looks like now:
case $mailer in
*sendmail)
# formail -X From: extract from header
# formail -rcx To: create a reply header, and then
# extract the value of the To: header
# tr -d ' ' remove whitespace
from=`formail -X From: <$tmpart |formail -rcx To: |tr -d ' '`
case "X$from" in
X) fromarg= ;; # no from available
X*) fromarg='-f "'"$from"'"' ;;
esac
echo "$mailer $fromarg -t <$tmpart"
$mailer $fromarg -t <$tmpart
;;
Elijah
------
has been using Pnews and Rnmail directly for years