Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Using Procmail with formail to add headers and forward w/o causing a loop...

1,461 views
Skip to first unread message

Sam

unread,
Jan 13, 2003, 5:27:34 PM1/13/03
to
Hello All, This is my first post to a news group, so please be patient
if I inadvertently disobey some unspoken rules. I'll try to be as
succinct as possible.

Here's my problem: I need any mail coming in from a particular domain
to be sent to the original recipient and two other people in my
company. I keep getting mail loops with my current procmailrc, so I
attempted to implement some of the mail loop solutions using formail.
No luck. :-) I'm a newbie to any type of mail processing so I'm sure I
am just missing some very simple step. It would be a big help if
someone would take the time to check out my procmailrc.

-/etc/procmailrc-

:0c
* ^From.*thedomain.com #Match the particular domain
* ! ^X-Loop: thedomain.com #Check for the anti-loop header
| formail -A "X-Loop: thedomain.com" #Set anti-loop header if needed
! User1 User2 #Now send it to these guys also


I don't have a complete understanding of the flow procmail uses, so
please keep in mind my inexperience. Thanks!

-Sam

"A cup brimful of sweetness cannot spill even one drop of bitter
water, no matter how suddenly jarred." -Amy Carmichael

Tim Heaney

unread,
Jan 13, 2003, 8:36:40 PM1/13/03
to
dahir...@hotmail.com (Sam) writes:
>
> Here's my problem: I need any mail coming in from a particular domain
> to be sent to the original recipient and two other people in my
> company. I keep getting mail loops with my current procmailrc, so I
> attempted to implement some of the mail loop solutions using formail.
> No luck. :-) I'm a newbie to any type of mail processing so I'm sure I
> am just missing some very simple step. It would be a big help if
> someone would take the time to check out my procmailrc.
>
> -/etc/procmailrc-
>
> :0c
> * ^From.*thedomain.com #Match the particular domain
> * ! ^X-Loop: thedomain.com #Check for the anti-loop header
> | formail -A "X-Loop: thedomain.com" #Set anti-loop header if needed
> ! User1 User2 #Now send it to these guys also

You can only have one action line (you can't pipe it to formail *and*
forward it). However, that one action line can have multiple things
piped together, so after formail is done with it, give it to sendmail
(or whatever your agent is) directly. That is, something like

:0c
* ^From.*thedomain.com
* ! ^X-Loop: thedomain.com
| formail -A "X-Loop: thedomain.com" | $SENDMAIL -oi User1 User2

should do what you want. Note that if the line gets too long for your
liking, you can use a \ for a continuation line. That is,

| formail -A "X-Loop: thedomain.com" | \
$SENDMAIL -oi User1 User2

still counts as one line.

I hope this helps,

Tim

Sam

unread,
Jan 14, 2003, 10:54:43 AM1/14/03
to
Tim:

Excellent help! My problem is resolved. Many thanks for your quick
reply and the use of your expertise.

-Sam

0 new messages