LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Using procmail to forward a copy of mails (https://www.linuxquestions.org/questions/linux-software-2/using-procmail-to-forward-a-copy-of-mails-413393/)

J_Szucs 02-09-2006 07:00 AM

Using procmail to forward a copy of mails
 
I am trying to setup a procmailrc rule to forward a copy of each mail to an other (external) mail address.
Here is my present rule:
:0c
* !^FROM_DAEMON
* !^X-Loop: abcdefgh@foo.bar
| formail -A "X-Loop: abcdefgh@foo.bar" -I "Cc:" -I "Bc:" | $SENDMAIL -oi -t $newaddress

The problem is that the above rule does not only send the mail to "$newaddress", but also sends a copy to the address given in the "To:" field of the mail (besides, it also sends it to $LOGNAME@foo.bar).

What is the problem with the above procmailrc rule? Why are all mails sent to the "To:" address, too?

unSpawn 02-09-2006 01:18 PM

The "c" in your procmail recipe means "CC".

J_Szucs 02-09-2006 02:31 PM

> The "c" in your procmail recipe means "CC".

Well, actually "c" does not really matter; e.g. if I modify the rule like this:

:0
* !^FROM_DAEMON
* !^X-Loop: abcdefgh@foo.bar
| formail -A "X-Loop: abcdefgh@foo.bar" | $SENDMAIL -oi -t $newaddress

then the mail will still be sent to two addresses: to the "To:" address, and to "$newaddress".

I simply do not understand why?
Is it sendmail or procmail that causes this unwanted behaviour?

P.S.
Naturally, it would be easy to have formail change the "To:" address to the same as "$newaddress", but then the user cannot find out by one glance that this is a redirected mail. (Plus there is a chance that two mails would be sent to "$newaddress", then?!)


All times are GMT -5. The time now is 06:42 PM.