procmail
[Top] [All Lists]

Re: Mail filtered to two mailboxes

2002-02-21 17:43:45
At 18:23 2002-02-21 -0500, Tim Holmes did say:
What I want to do is, is take an email from a users, and put it in to two
mailboxes.

Q: by mailbox, do you mean a separate mailbox file, or an actial separate _user_ mailspool? They're VERY significantly different. The latter is accomplished by forwarding a copy of the message...


Pick one:
        A. From a local user to a specific local user
        B. From a local user to YOU (with copy to other user)
        C. From you to another local user (you want a copy)
        D. From a local user to just anyone
        E. From a remote user to a specific local user
        F. Something else

Draw the line to the answer:

        A. Doable (in /etc/procmailrc)
        B. Trivial (within your own .procmailrc)
        C. Doable (in /etc/procmailrc)
        D. Must be accomplished within the MTA config (procmail isn't an MTA).
        E. Doable (in /etc/procmailrc)
        F. Please elaborate.

So every email coming in from user1(_at_)domain(_dot_)com is then copied into 
mailbox
user1 and into mailbox personal.

(Q: is "domain.com" your host, or somewhere else, and is it "coming in" to a specific local user?)

The (untested) /etc/procmailrc solution would be:

:0c
* ^From:.*\<user1(_at_)domain\(_dot_)com
* ! ^X-Loop: ourdomain\.fwd
| formail -i "X-Loop: ourdomain.fwd" | $SENDMAIL user_to_copy_to

This adds the x-loop header to the copy which is being forwarded.

I've never tried (and you'd definatley want to test it before stuffing it into a live config, say by triggering off of your address and a SPECIFIC test subject), but you could pipe the copied message to procmail for local delivery:

:0c
* ! LOGNAME ?? user_to_copy_to
* ^From:.*\<user1(_at_)domain\(_dot_)com
| procmail -Y -a $1 -d user_to_copy_to

If executed from /etc/procmailrc, procmail will already be running as root, so the explicit delivery mode should work as expected. I would expect procmail to re-invoke the /etc/procmailrc, which is why the rule doesn't invoke if the user to be delivered to IS the user we'd be forwarding it to (which even if this weren't a delivery of the copy itself, would make the rule annoying otherwise).

If instead, YOU are the intended recipient, and you want it copied to another user, you'd use code like the first rule above, but place it within your own .procmailrc.

I basically Bcc myself for all these messages, so I have all the email sent
and recieved in one mailbox.  Just as back up copy in a way.

This would imply condition C above, the messages originating FROM you.

---
 Sean B. Straw / Professional Software Engineering

 Procmail disclaimer: <http://www.professional.org/procmail/disclaimer.html>
 Please DO NOT carbon me on list replies.  I'll get my copy from the list.

_______________________________________________
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>