Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Greetings,

I posted a question last night regarding using Mail::Audit to have mail placed in a folder directly forward to another email account, using sendmail. Does anyone know how to make a .forward file to only forward mail in a particular folder? Also, how often would this forwarding check for entries in the folder?

thanks much.

jc

Replies are listed 'Best First'.
Re: follow up on forwarding
by cianoz (Friar) on Jul 28, 2003 at 08:17 UTC
    if you want to use Mail::Audit then the only thing you need to put in .forward is
    | /your/mailauditscript.pl
    then using Mail::Audit methods inside your script you can accept() a centain message in a certain folder and/or resend() it to another address
    Read The Fine (Mail::Audit) Manual .
Re: follow up on forwarding
by DrHyde (Prior) on Jul 28, 2003 at 10:47 UTC
    Can't be done using .forward. Another poster has suggested how you *should* solve your problem. However, if you really do want to drop mail into a folder and have it then be forwarded onwards ... Depending on exactly how your mail is set up, a "folder" will either be a file or a directory. You need to write a program which will run periodically or will be triggered by the write to the file (which would really be a named pipe) to do the mail forwarding. Or use Plan 9, whose funky filesystem would seem to make this easy :-)
Re: follow up on forwarding
by saintbrie (Scribe) on Jul 28, 2003 at 14:28 UTC

    Procmail might serve your needs better, actually, as it allows some greater flexibility. It works like filters for netscape's mail client, but is configured at the server level via a text file in the user's home directory. (And it is a lot easier than it looks). There's a pretty solid tutorial for it here: at infinite ink. Most *nix systems come with procmail installed.

    I don't know your requirements exactly. How are you getting the mail in a particular folder to that particular folder? Is it possible that that system could forward the mail in addition to sorting it?

      People uses to still call it Sendmail but normally it is Procmail that even acts as if it were Sendmail.

      Other MTAs might also have a .forward local folder to put a list of addresses to forward if certain rules happen with the incoming email.

      Those rules might even call certain scripts! Well perl and GNU-Linux are from my point of view, the same family!