Author: David A. Sinck Date: Subject: changing "From" header in a script
\_ SMTP quoth Lynn David Newton on 1/21/2003 09:20 as having spake thusly:
\_
\_
\_ Greetings,
\_
\_ I have a need to change the "From" header in email from
\_ within a script. Does anyone know -- is formail(1) the
\_ key to doing that, or something else? We have a daily
\_ cron job run as root we'd like to filter specially.
There's a couple of points of confusion:
* do you want to filter
* do you want to cosmetically adjust From lines
* do you want to direct email output from cron to a non-default account
Each of those has a slightly different answer.
A sample procmail recipe is:
:0 Wf
* ^To.*Undisclosed | formail -A "X-Trapped-Rule: unlisted services" :0 a
spam-bot
"If it looks like "To <something> Undisclosed" (eg: "... recipients"),
add a header via formail mentioning reason, then (:0 a) toss it in the
spam-bot folder."
That's along the lines of the 'filter' question, but some parts are
left as an exercise for the reader. :-)
If you want minor cosmetic adjustments (option 2), it depends on how
you're sending mail from cron. If you're just dumping to stdout and
letting cron forward, then perhaps you need to alter your job to send
mail itself. At that point you'll control the horizontal and vertical
of your mail and you can set your From headers however you like.