Copying all mail to Archive
The following is probably made obsolete by
this .[note added 13July2005
One of the most common questions on comp.mail.sendmail is "How do I
get sendmail to archive copies of outgoing mail". This question is usually
left unanswered, as the more influential members of the sendmail community
think that is an improper action. They are apparently thinking of an ISP
snooping on its customers. I expect the more likely case is a business
such as a brokerage which is legally required to keep copies of
correspondence, for understandable reasons.
Some mailers make this easy. Postfix has "bcc: always" option that
solves this problem with a single request.
Anthony C Howe has posted milter-bcc
appears to duplicate the Postfix ability in Sendmail.
See also Synonym from Modulo
The Sendmail FAQ does offer three suggestions for doing this, but
except for one, they require extensive modification to sendmail, and it is
clear that they are not offered in the expectation that they will be
In the FAQ, and in the newsgroup, it is also suggested that Procmail
can do this. Most people making this suggestion are merely confused, since
if you install procmail as documented, it only sees incoming mail. Since
it never sees outgoing mail, it isn't going to be able to save copies.
However it turns out that there is a way to install procmail to process
outgoing mail. I haven't tried it myself, but I did track down the
available instructions, and have copied them below. There is obviously
room for someone to actually try to document this in simple terms for
sendmail users of less than guru status. As a start, one could consult this . [Note added
September 2005 - Procmail scanning of outbound mail has apparently been
added to Sendmail, if not to the FAQ. See
The sendmail FAQ includes a reference to a comp.mail.sendmail posting
using only 33AA593A.4B701C3F@syntegra.nl for the citation. While
some users might know to go to the Google Groups "Advanced Search" page,
others may not. I expect this page will come up for anyone searching in
the Google web engine for that message-id, thus letting the uninitiated
see the posting referred to.
Viewing message <33AA593A.4B701C3F@syntegra.nl>
From: Homme Bitter (H.Bitter at syntegra dotte nl)
Subject: Solution for copying all mail to archive
View: (This is the only article in this thread) | Original Format
It took me some time, but,
I have it solved...
This can also be used as a general purpose mailfilter too, excellent for
detecting spam and other unpleasant things.
Let sendmail map everything through procmail, let procmail do to your
mail whatever you want with it and map it back.
That was the easy part...
Now for the syntax.
Add some local rules to your m4 config file ( use m4, ALWAYS ! ).
R$*<@$*.procmail>$* $1@<$2>$3 map back of procmail copy
R$*<@$+>$* $#procmail $@/etc/procmailrc $:$1@$2procmail$3 send all
external mail to procmail
this will send all mail through procmail using the file /etc/procmailrc
as the config file for procmail.
I use this one:
Once I found this all out ( with a little help, I might add ). it all
seemed so simple....
Maybe this would be a good item to add to the faq, since it is a general
purpose add on for sendmail that can be used for many useful purposes.
Sending to a top leve domain doesn't work, it somehow looses a dot, but
then again, there are no mailaddresses in toplevedomains, to my
knowledge, so, who cares.
This version only works for mail wit a @ sign in the address, it's kind
of hard to split up an address that consists of only one string.
Good luck, I hope the mail-commutity is happy with this.
Also see this message:
From: Per Hedeland (email@example.com)
Subject: Re: Using procmail to archive outbound fails - buildaddr: no user
View this article only
Date: 2002-04-13 03:30:06 PST
In article Harry Putnam
> R$*<@$*.procmail>$* $1@<$2>$3 map back of procmail copy
> R$*<@$+>$* $#procmail $@/etc/procmailrc $:$1@$2procmail$3 send all
> external mail to procmail
>After first getting the tabs right (I think), I inserted the above
>into my.mc and generated sendmail.cf
You *didn't* get the tabs right - it should be like this (no need for
multiple LOCAL_RULE_0 directives), where I have used instead of
R$*<@$*.procmail>$*$1@<$2>$3map back of procmail copy
R$*<@$+>$*$#procmail $@/etc/procmailrc $:$1@$2procmail$3send all
external mail to procmail
Btw, it's probably better to do this with a milter these days.
Here is the entire