procmail
[Top] [All Lists]

Re: Forward mail with From in subject field

1997-02-19 02:07:21
On Wed, 19 Feb 1997 08:44:00 +0100 (MET), Jarl Groneng <gjarl(_at_)sn(_dot_)no>
wrote:
I have a little problem. I want to forward mail to another e-mail account 
with the sender in the subject field. So I need a program/script that 
take out the sender and put it in the subject field on the forwarded 

Try this:

    FROM=`formail -rtzxTo:`

    :0
    * Some condition you want to match before doing this, perhaps? 
    | formail -I"Subject: $FROM" | sendmail 
address(_at_)to(_dot_)forward(_dot_)to

Add a "c" flag if you also want to proceed with normal processing of
this message in addition to forwarding it. 

mail/new mail. I also want the forwarded mail to go tru a filter-list 
that is built like a list with som people, like the e-mail adress.

On which field? Filter out some people from whom you don't want to
forward mail? 

The "* Some condition ..." line would then become

    * ! ? fgrep -is "$FROM" filename-of-file-with-guys-to-filter

Messages which don't get forwarded will simply fall through in this
scheme. Check the procmailex(5) manual page for some more examples and
you should be able to construct a filter to your liking. 

Hope this helps,

/* era */

Troubles you will have: sendmail will probably not be in your path.
Often one defines SENDMAIL=/etc/lib/sendmail at the beginning of the
.procmailrc and then refers to $SENDMAIL in the actual recipes. Also,
test this before you put it in use (I haven't :-) Finally, set the log
to VERBOSE and look at what kind of values FROM is actually getting.
You will want complete valid e-mail addresses (no comments such as
real names etc) in the filter file.

-- 
Defin-i-t-e-ly. Sep-a-r-a-te. Gram-m-a-r.  <http://www.iki.fi/~era/>
 * Enjoy receiving spam? Register at <http://www.iki.fi/~era/spam.html>

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