procmail
[Top] [All Lists]

Re: Forwarding messages and saving them on a POP account

1997-10-28 09:47:59
Arthur from the Islanders List asked,

| Take incoming e-mail and forward it to an e-mail address while saving it in
| the POP mailbox.

Check the procmailrc(5) man page and read about the `c' flag.  It tells
procmail to operate on a _c_opy of the message and to go on processing later
recipes to handle the original.

| The same as above and copying it to a folder on the server.
| 
| :0
| * ^TOusername
| * !^FROM_DAEMON
| ! anotheruser(_at_)someotherdomain(_dot_)com
| 
| :0
| * ^TOusername
| $HOME/public_html/admin/mail/username
| 
| 
| At present, only the first recipe is processed, and the mail is removed
| from the POP mailbox. Can I make both work on the same message?

Add a `c' flag (so that it starts :0c) to the first recipe.  While you're
at it, the second one probably needs a local lockfile.  Nesting the two
would be a good idea to save the double search for ^TOusername, as well:

  :0
  * ^TOusername
  {
   :0c
   * ! ^FROM_DAEMON
   ! anotheruser(_at_)someotherdomain(_dot_)com

   :0:
   $HOME/public_html/admin/main/username
  }

| I've also put this recipe at the bottom:
| 
| :0
| * ^TO.
| ! postmaster(_at_)somedomain(_dot_)com

You might as well have simply this, unless you specifically want not to
forward mail that lacks a match to ^TO.:

  :0
  ! postmaster(_at_)somedomain(_dot_)com

and forward unconditionally if procmail gets that far in your rcfile without
delivery.

| Is there any way to keep this recipe while saving a copy of all incoming
| mail to the POP mailbox?

You want ALL incoming mail saved to the POP mailbox regardless of what
procmail does with it?  If you are calling procmail with a .forward, then
in your .forward, you can put this:

 /path/to/POP/mailbox, "|pipe to call procmail"

Otherwise, put

  :0c:
  path_to_POP_mailbox # absolute from / or relative from $MAILDIR

near the top of your .procmailrc, before any recipes that deliver elsewhere.

Arthur also asked,

| Is there a recipe to forward messages to two or more addresses?

Sure thing; just separate the addresses with spaces:

  :0 flags
  * conditions
  ! ad(_at_)dre(_dot_)ss1 ad(_at_)dre(_dot_)ss2 ad(_at_)dre(_dot_)ss3 ...

<Prev in Thread] Current Thread [Next in Thread>