Help configuring fetchmail

Jeremy Turner jeremy at linuxwebguy.com
Wed Oct 13 14:44:53 CDT 2004


On Wed, October 13, 2004 1:52 pm, linux at bizniche.com said:
> Jeremy Turner <jeremy at linuxwebguy.com> wrote on 10/13/2004, 08:37:16 PM:
>> On Wed, October 13, 2004 1:26 pm, linux at 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 at ... 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

-- 
Jeremy Turner <jeremy at linuxwebguy.com>
Linux Tips and News! ---> http://linuxwebguy.com




More information about the Kclug mailing list