0

I use procmail to handle some serverside mail processing. I am trying to setup one email address on a server that support multiple domains (in the example below, domain.net and domain.com). I want mail sent to user@domain.net to go to bob and mail sent to user@domain.com to go to sara.

VERBOSE=off
LOGFILE=/dev/null

:0
* .domain.net
bob

:0
* .domain.com
sara

The above recipe seems to work quite well in that it catches incoming mail to domain.net and forwards it to bob.

However, instead of forwarding mail to domain.com to sara, it creates a file in /home/user called sara.

What am I doing wrong on this?

warren
  • 18,369
  • 23
  • 84
  • 135

1 Answers1

2

You're delivering to a local file, not forwarding the message on to users. Also (as you pointed out in your comment) you aren't carbon-copying the message, so delivery stops after the first matching rule.

# 'c'opy the message to deliver it twice.
# ! to forward the message
:0 c
* .domain.net
! bob

:0
* .domain.com
! sara

The prcomailrc manpage says:

Anything else will be taken as a mailbox name (either a filename or a directory, absolute or relative to the current directory (see MAILDIR)). If it is a (possibly yet nonexistent) filename, the mail will be appended to it.

The best way to debug procmail issues is to set verbose and logfile in your .procmailrc. Examining the logfile will go a long way toward revealing why procmail is acting a particular way.

EDIT: Updated with carbon-copy info based on OP comment.

Phil Hollenback
  • 14,947
  • 4
  • 35
  • 52
  • Yes, without the bang (!) symbol, the recipe says to deliver to local file. – Robert Novak Mar 07 '11 at 22:11
  • 2
    Also, you might want to use something like ^TOdomain.net to be more precise in your targeting. The recipes as listed (I think) will match any header containing .domain.net or .domain.com, including the subject. – Robert Novak Mar 07 '11 at 22:12
  • thanks! the other component I need is a ` c` after the `:0`, so it not looks like `:0 c`. – warren Mar 07 '11 at 22:23