Re: [SLUG] Re: fetchmail into different folders based on pop3 account

From: Paul M Foster (paulf@quillandmouse.com)
Date: Mon Apr 25 2005 - 18:54:54 EDT


On Mon, Apr 25, 2005 at 05:23:55PM -0400, Alex Harris wrote:

> I need to somehow pass a variable (on what directory to use) to the
> .procmailrc file, from a shell script that I'm running which calls
> fetchmail which in turn calls procmail.
>
> I can't filter based on the information on the To; line though as much
> of the e-mail I get doesn't have the actual address it's being
> delivered to in the "To" line (a lot of them are bcc's).
>
> Any ideas as to why
> DEFAULT=.$RMAILU/
> wouldn't work?

Well, first off, you can't just pass variables to a program unless it's
expecting them. Some programs will pay attention to the environment
variables, but I don't know if procmail is one of them.

You _could_ do this this way-- at the top of your .procmailrc file,
insert a line like:

INCLUDERC=/home/joe/.mail-address-to-use

In the /home/joe/.mail-address-to-use file, you'd put a line like:

DEFAULT=/home/joe/Mail/personal

Your script file might look like this:

#!/bin/bash

echo "DEFAULT=/home/$1/Mail/personal" > /home/joe/.mail-address-to-use
fetchmail

where $1 is the username you want to use (or whatever). You'd call it
like:

$ myscript joe

and proceed from there. But this is a very kludgy solution.

All this kind of begs the question of why you're doing it this way. It
sounds like you're trying to run fetchmail on various pop servers, and
then dump the mail into a single user account, but separate folders,
based on the pop3 account you're fetching. Is that right?

If that's the case, you can still use procmail in the "standard" way by
filtering on headers instead of the "To:" line. You can examine the mail
you get from the various servers and find what's unique to each one.
Perhaps a "Delivered-To:" header or a "Received-By:" header. For each
recipe that succeeds, you can dump that mail into a different email
folder.

Here's another point: Normally DEFAULT is the central mail store for a
given user, like /var/mail/joe. MAILDIR is where the mail will go if a
recipe tells it to go to $MAILDIR. Normally, procmail will deliver to
$DEFAULT, and many email clients (like mutt) will look there for the
mail by default. They won't look in some other subdirectory of /home
unless you explicitly tell them to.

Paul

-----------------------------------------------------------------------
This list is provided as an unmoderated internet service by Networked
Knowledge Systems (NKS). Views and opinions expressed in messages
posted are those of the author and do not necessarily reflect the
official policy or position of NKS or any of its employees.



This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 18:02:30 EDT