I have problems using the arguments passed to procmail by the caller.
I need to store in a unique mailbox all the mail that arrives for one domain,
and later, filter the mailbox using the destination address.
Using a rewriting rule of the form (sendmail.cf):
is not adequate for my case because lot of mails (for example those that come
from a mailing list) does not contain a "To:" field, so the mailbox cannot be
re-filtered based on the destination address.
Also, I cannot use the sendmail option:
because if there are several destination addresses all of them are included,
inhibiting further filtering.
I have decided to use the procmail mailer as defined in the procmail man pages:
R$*<@domain.com.>$* $#procmail $@/etc/procmailrcs/domain
R$*<@$*.procmail>$* $1<@$2>$3 Already filtered, map back
with the mailer defined as (without the m Flag, of course):
Mprocmail, P=/usr/bin/procmail, F=cDFMShu, S=11, R=21,
A=procmail -m $h $f $u
Then I want to use procmail to add a field, say X-To, including the $u
that is, the real destination address.
But I cannot access the arguments inside the rcfile, so I cannot do it.
Which is the reason I cannot access them?
Is it due to a security problem?
I have found a very ugly solution:
Create myprocmail as a script:
formail -I "X-To: $3" | procmail -m $*
and define the procmail mailer as:
Mprocmail, P=/usr/bin/myprocmail, F=cDFMShu, S=11, R=21,
A=myprocmail $h $f $u
But I hope that there exists a more elegant solution.