On Sat, 8 Oct 2005, Lord Raiden wrote:
LR> I'm curious what I need to put in my procmail file to take mail
LR> destined for a given user and sort it into the appropriate mailbox on the
LR> server. Right now fetchmail pulls all our mail from a central ISP mailbox
LR> and dumps it into one mailbox here on the local mail server. I'd like to
LR> be able to take mail messages destined for specific users and dump those
LR> messages into their individual mailboxes on the mail server.
LR>
LR> So like if a message is addressed to "bob(_at_)raiden(_dot_)net"
it would get
LR> sorted into bob's inbox and he could then pop it directly from the
LR> server. I'm assuming that mail would then be sorted based on spam or other
LR> criteria from there so that any spam that is filtered for "bob" would go
LR> into his own spam folder on the server. If not, is there something special
LR> I'd have to do to make that happen as well?
LR>
Tricky.
First of all, read "man fetchmail", the section entitled THE USE AND
ABUSE OF MULTIDROP MAILBOXES. You may be able to do it with fetchmail.
You need to know a few things about your mail. Take an example of a mail
sent to four people with, say you(_at_)example(_dot_)com and
him(_at_)example(_dot_)com in the
to: field, them(_at_)example(_dot_)com in the cc: field and
someoneelse(_at_)example(_dot_)com
in the bcc: field. OK, get that sent now to your server.
Have you received 1, 2, 3 or 4 copies via fetchmail? Do the headers of
each contain a header such as x-envelope-to: with the name of the
recipient? If not, then you will need a bit of procmail trickery on the
headers but the chappie in the bcc: header will be lost forever. Not to
be recommended but below are the rather crude recipes I seemed to have
used:
# -------------- cut here --------------------------------
# all mail, excepting previously handled - temporary for safety
:0 c:
IN.allacmail
# get the to and cc headers
# this appears to put a blank before the start
:0 w
TOCCHEADER=| formail -x To: -x Cc:
# save to and cc headers to a files
:0 c:
| formail -x To: -x Cc: > toccheaderfile
# example.com mail
:0
* TOCCHEADER ?? @example\.com
{
# To margaret
:0 c
* TOCCHEADER ?? [^-a-zA-Z0-9_(_dot_)]margaret(_at_)example\(_dot_)com
! margaret
# To test
:0 c
* TOCCHEADER ?? [^-a-zA-Z0-9_(_dot_)]test(_at_)example\(_dot_)com
! test
# To proctest
:0 c
* TOCCHEADER ?? [^-a-zA-Z0-9_(_dot_)]testtest(_at_)example\(_dot_)com
! test
# is it for alan or unknown?
:0:
# add a +1 to ensure positive rather than 0
* 1^0 TOCCHEADER ?? @example\.com
# subtract 1 for each example.com
* -1^1 TOCCHEADER ?? @example\.com
# add one for each of the names specified above
* 1^1 TOCCHEADER ?? [^-a-zA-Z0-9_(_dot_)]margaret(_at_)example\(_dot_)com
* 1^1 TOCCHEADER ?? [^-a-zA-Z0-9_(_dot_)]test(_at_)example\(_dot_)com
* 1^1 TOCCHEADER ?? [^-a-zA-Z0-9_(_dot_)]testtest(_at_)example\(_dot_)com
# if positive, then not for alan or unknown
IN.notforalan
}
# -------------- cut here --------------------------------
Note that I didn't deliver to mailboxes, I forwarded mail to users. I'm
not sure why I did this but it would actually be appropriate in your case
as the users .procmailrc files could filter for spam. This was run in
alan's .procmailrc so alan's mail falls of the end an is delivered or
processed further.
--
Alan
( Please do not email me AS WELL as replying to the list. Please
address personal email to alan+1@ as lists@ is not read. A
password autoresponder may be invoked if this email is very old. )
____________________________________________________________
procmail mailing list Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail