procmail
[Top] [All Lists]

Re: Forwarding question

2000-12-05 18:05:28
On Tue, Dec 05, 2000 at 05:18:17PM -0500, Theresa Peter wrote:
Is it possible or has someone already written a program that will take 
someone's mailbox and forward all mail to another account and then remove 
those messages off of the system?

formail -s formail -I "To: newaddress(_at_)domain" < spoolfile | sendmail -oi 
-t ; rm spoolfile

Determinig which files to apply this to and the value of 
"newaddress(_at_)domain"
should be fairly scriptable.

For instance, if you're using .forward files in user home dirs, perhaps
something along the lines of:

for a in `find /home -name .forward 2>/dev/null`; do
        FORWARDER=`dirname $a`
        TOADDR=`cat $a`
        formail -s formail -I "To: $TOADDR" < /var/spool/mail/$FORWARDER | \
        sendmail -oi -t
        rm /var/spool/mail/$FORWARDER
done

Note the line that begins "sendmail" is continued from the previous line.
Of course, replace paths as appropriate for your system.

If you're using sendmail aliases, awk would be called for, but that's beyond
my ability without the Awk book hand, and that's at home.

        

-- 
Andrew Edelstein                http://andrew.pure-chaos.com

"? Callous? Why, yes, actually, yes I am."
                                Latheos, 28 Apr 2000
_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

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