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

From: Alex Harris (nccuss17@gmail.com)
Date: Mon Apr 25 2005 - 17:23:55 EDT


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?

On 4/25/05, Paul M Foster <paulf@quillandmouse.com> wrote:
> On Mon, Apr 25, 2005 at 10:14:00AM -0400, Alex Harris wrote:
>
> > I am trying to create a setup where I can dump all my pop3 accounts
> > into one account on my linux server (so that I can access via imap and
> > MAILDIR).
> >
> > What I need is a way to have the messages retrived from each pop3
> > account that fetchmail accesses go into a separate MAILDIR folder.
> > I've heard that procmail seems to be the way to go for this:
> > "mda '/usr/bin/procmail'" but I can't seem to get procmail to save the
> > messages into different folders based on based on the pop3 username.
> > I've tried passing enviroment variables to the .procmailrc but it
> > doesn't seem to like the following line:
> > DEFAULT=.$rmailu/ <-$rmailu is "remote mail user"
> > I've already have the line "MAILDIR=/home/linuser/Maildir/" above the
> > default line.
>
> Procmail has several man pages: procmail, procmailrc and procmailex. The
> procmailrc man page details the structure and syntax for the .procmailrc
> file. The procmailex file contains examples of working .procmailrc
> files.
>
> In order to do what you want, you're going to have to learn how to tweak
> your .procmailrc file. The .procmailrc file contains various "stanzas"
> which indicate what it's supposed to look for in emails, and what to do
> with the mail. It checks each stanza in the file, and if that email
> matches the stanza, it sticks the email where the stanza says to stick
> it. If the email doesn't match the stanza, it goes on to the next stanza
> to check that one.
>
> A typical stanza in a .procmailrc file might look like this:
>
> :0:
> * ^To:.*joe@jones\.com
> /home/joe/Mail/personal
>
> Every stanza in a .procmailrc must begin with (at least) ":0". Adding
> the colon (:) on the end tells procmail to lock the destination file
> before appending mail to it. This is important where multiple processes
> might access that file at the same time.
>
> The second line tells what you're looking for, and must normally start
> with a star (*) (for exceptions, see the man pages). What follows is
> similar to a regular expression. The caret (^) says to match whatever
> follows at the beginning of the line. The "To:" just means you want to
> look for something on the "To:" line of the email. The ".*" says you
> want to match anything that follows (a name, spaces, or whatever). The
> last part is the email address you're looking for. It's modified by the
> backslash (\) before the dot (.) because a dot by itself means any
> single character. You "backslash" (or "escape) it to mean you're looking
> for just a dot, not any character.
>
> The last line tells procmail what to do with the mail, if it matches the
> line above. In this case, procmail is supposed to put it in the
> /home/joe/Mail/personal folder.
>
> If you want to stick your mail into maildir folders, you might modify
> the stanza (or "recipe") this way:
>
> :0:
> * To:.*joe@jones\.com
> /home/joe/Mail/personal/.
>
> This will deliver the mail to something like:
>
> /home/joe/Mail/personal/2344
>
> Or you can do this:
>
> :0:
> * To:.*joe@jones\.com
> /home/joe/Mail/personal/
>
> This will deliver the mail to something like:
>
> /home/joe/Mail/personal/new/2344
>
> (Don't hold me to the exact way this works with MAILDIR delivery. I've
> never done it, and am only going by the man pages. But it's close.)
>
> Obviously, you can substitute this for something like:
>
> $MAILDIR/personal/
>
> or
>
> $MAILDIR/personal/.
>
> You can also test your setup by piping a sample email to procmail to see
> what it does with it, like:
>
> cat samplemail | procmail
>
> You can also turn on procmail logging to see the exact steps procmail
> goes through to deliver the mail.
>
> Hope this helps.
>
> 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 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:01:55 EDT