Jeremy Turner jeremy@linuxwebguy.com wrote on 10/13/2004, 08:37:16 PM:
On Wed, October 13, 2004 1:26 pm, linux@bizniche.com said:
That sounds exactly like what I want to do. I guess I get confused because I often see procmail and exim mentioned in the same context...leading me to believe they do the same thing.
So, all I need to add is procmail. Currently, I guess exim sends the mail to my Maildir...and now I need to tell it to send to procmail instead. I'll read up on procmail and see how it might fit in.
If you're using Debian, you can 'apt-get install procmail' then create yourself a ~/.procmailrc file. exim in woody and in sarge is setup to check for procmail _before_ delivering to maildir, unless you set it up differently. Basically, if the procmail transport is listed before the maildir transport, you're okay.
I am using debian, but while trying to get it working, I did change the exim conf to use maildir. The related section looks like this:
local_delivery: driver = appendfile group = mail mode = 0660 mode_fail_narrower = false envelope_to_add = true return_path_add = true directory=${home}/Maildir maildir_format = true prefix=""
Is this the trasport that you mentioned? What does a procmail setup look like?
I also see this procmail section in the conf file, but I'm not sure if it's doing anything.
procmail_pipe: driver = pipe command = "/usr/bin/procmail" return_path_add delivery_date_add envelope_to_add # check_string = "From " # escape_string = ">From " suffix = ""
Now what should go in your .procmailrc? I used to list all of my mailing lists by hand, then I found this script:
http://www.dotfiles.com/files/12/215_.procmailrc
This procmailrc will attempt to dynamically check for certain headers in the email and then deliver them into that folder. It works great 99% of the time. The only problem is that one mailing list uses the email address of "talk@...." so that mailing list gets put under the 'talk' folder. KCLUG, however gets put under the 'kclug' folder.
The drawback is that if SpamAssassin (or your spam solution) doesn't catch an email and the spam email has a header that _looks like_ it's from a mailing list, then it creates a new folder to put the mail in. I have a couple of folders that were created in this way.
But like I said, 99% good.
So, you're using it to filter mail into folders, and the mail is all coming from the same email account, correct? I have fetchmail checking a few different pop3 accounts, and so I could probably filter by the to: address or something, and place them in different folders, as you say. Either way, fetchmail will dump it all into one place and then procmail can filter it. Right?
Matt
On Wed, October 13, 2004 1:52 pm, linux@bizniche.com said:
Jeremy Turner jeremy@linuxwebguy.com wrote on 10/13/2004, 08:37:16 PM:
On Wed, October 13, 2004 1:26 pm, linux@bizniche.com said:
That sounds exactly like what I want to do. I guess I get confused because I often see procmail and exim mentioned in the same context...leading me to believe they do the same thing.
So, all I need to add is procmail. Currently, I guess exim sends the mail to my Maildir...and now I need to tell it to send to procmail instead. I'll read up on procmail and see how it might fit in.
If you're using Debian, you can 'apt-get install procmail' then create yourself a ~/.procmailrc file. exim in woody and in sarge is setup to check for procmail _before_ delivering to maildir, unless you set it up differently. Basically, if the procmail transport is listed before the maildir transport, you're okay.
Oops.. I meant router, not transport. You need an entry in transport and router, but order _does_ matter in the router section, and not in the transport. Therefore, the procmail router should be listed before the maildir or in your case "local_delivery".
Basically, exim will go down the router list and say "do I match this router condition?" It will get to procmail and say "Do I have /usr/bin/procmail and ~/.procmailrc for the user?" If those two conditions exist, then it delivers the mail to procmail
Is this the trasport that you mentioned? What does a procmail setup look like?
For procmail, you will need to have the procmail router and transport. The procmail_pipe is the transport. It basically tells exim what to do with the email should the procmail router match.
Here is my procmail router
********* procmail: debug_print = "R: procmail for $local_part@$domain" driver = accept domains = +local_domains check_local_user transport = procmail_pipe require_files = ${local_part}:${home}/.procmailrc:+/usr/bin/procmail no_verify no_expn *********
The transport line says, if this matches, then call the procmail_pipe transport to know where to deliver the email. This particular router verifies that the intended recipient is infact a local user, and then checks the required_files for a .procmailrc and /usr/bin/procmail file. If those are present, then it calls the procmail_pipe transport. Mine looks like this:
************** procmail_pipe: debug_print = "T: procmail_pipe for $local_part@$domain" driver = pipe path = "/bin:/usr/bin:/usr/local/bin" command = "/usr/bin/procmail" return_path_add delivery_date_add envelope_to_add **************
The command line will pipe (see the driver line) the full email to that command. Procmail will then figure out who it goes to and read the .procmailrc file to figure out how to deliver it. A simple procmailrc file for maildirs would look something like this:
************** HOME=/home/jeremy PMDIR=$HOME/.procmail LOGFILE=$PMDIR/log MAILDIR=$HOME/mail/ LOCKFILE=$PMDIR/.lockmail VERBOSE=no
# catch all for inbox :0 $MAILDIR ***************
So, you're using it to filter mail into folders, and the mail is all coming from the same email account, correct?
Ultimately, yes. I have many email aliases that I use instead of my real address for sites that want my email address. If Paypal (etc) give my address to third parties, I get spam to paypal@... which I can eventually turn off. It works for most things. But yes, everything goes into one email account.
I have fetchmail checking a few different pop3 accounts, and so I could probably filter by the to: address or something, and place them in different folders, as you say.
Yes you could do it that way. I believe fetchmail also adds some extra headers that would be a better match. Your fetchmail account could get an email which was BCC-ed to you. You couldn't match that with normal headers.
Either way, fetchmail will dump it all into one place and then procmail can filter it. Right?
Right. Clear as mud? =)
It took me a while to understand how this system all works together. There are several parts and they all have to work together. It can be complicated trying to get them to play nice and do what you expect.
I'm not the northeastern Kansas expert on procmail, exim, or courier-imap, but I managed to get it working on my home server.
Jeremy