procmail
[Top] [All Lists]

Re: Mails not flowing after segreting the mails

2001-02-22 11:36:07
On 22 Feb, Nilanjan Sircar wrote:
| Dear Sir
| 
|         I wrote following codes to transfer the mails
| from .com to one user(sysadmin) and other mails to
| another user (sales)
| but the problem is the mails from the .com are
| transfering to that user (sysadmin) but the other
| mails are not transfered to another user (sales).
| 
| :0c
| * ^TOsales(_at_)shrilcal(_dot_)virtualave(_dot_)net
| {
|  :0
|  * ^From:.*\.com
|   {
|     :0fhw
|     | formail -i "To:sysadmin(_at_)shrilcal(_dot_)virtualave(_dot_)net"
|             
|     :0
|     !sysadmin
| 
|   }
|  
|  :0e
|  !sales
| 
|  }
| 
| :0c
| * ^TOhrd(_at_)shrilcal(_dot_)virtualave(_dot_)net
| !hrd
| 
| What could be the problem as no mails are flowing to
| sales
 
The problem you think you want to solve is caused by the "e" flag on the
recipe that forwards to sales. That should be "E". "E" executes if the
preceeding recipe did not execute, while "e" executes if the preceeding
action failed.

But I think this error protected you from a loop. If mail comes in
addressed To: sales(_at_)shrilcal(_dot_)virtualave(_dot_)net from a non-*.com 
address,
you're forwarding it to sales, which will end up feeding it
continuously through this same recipe with the same results. Hopefully
your MTA would bail out after some number of cycles with an error re:
too many hops.  You probably don't need, or want, to forward this
message. First, unless the envelope recipient is not the same as
the condition match, the action "$DEFAULT" is going to put the message
in the same place as "! sales" but without starting the MTA/procmail 
process(es) again. So something like the following might work.

:0
* ^TOsales(_at_)shrilcal(_dot_)virtualave(_dot_)net
{
  :0
  * ^From:.*\.com\>
  {
    <no change from what you have in this block above>
    <but see final note>
  }
  :0 E:
  $DEFAULT
}

[Note: Eliminated "c" flag on outer recipe which is unnecessary
unless you're trying to do more than you've described. Also added "\>"
to end of condition above to prevent matching something like "From:
castro(_at_)havana(_dot_)communist(_dot_)org" ]

If you decide the risk that the envelope recipient may not be "sales" is
too high, then just change "$DEFAULT" above to "/var/spool/mail/sales"
or whatever the correct path is for your system. I think such a
mismatch is unlikely, and the worst thing that happens if you deliver to
$DEFAULT in this case is the message goes to the wrong place. That's
still better than /root/.dead.letter, and you don't have to remember to
change path names if your spool directory ever changes.

FWIW, I avoid forwarding locally at all costs, preferring to directly
deposit messages in the correct spool file if different from $DEFAULT.
I would do the same thing with your "!sysadmin" action. Maybe it's just
me and others will disagree, but I just don't see the need to invoke
sendmail/procmail again to put a message where I already know I want it.
So I'd change:

  :0
  !sysadmin

to:

  :0:
  /var/spool/mail/sysadmin

All of this assumes that sales and sysadmin are valid usernames and not
aliases. If aliases, then obviously you need to put them in the
corresponding user's mbox. You also need to change the spool directory
if necessary. And if sales or sysadmin are aliases for distribution to
multiple recipients then ignore everything. :-(

-- 
 /"\                                                 Don Hammond
 \ /     ASCII RIBBON CAMPAIGN
  X        AGAINST HTML MAIL,
 / \      AND NEWS TOO

_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

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