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 which appears to duplicate the Postfix ability in Sendmail. See also Synonym from Modulo Consulting.

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 implemented.

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 here.

The sendmail FAQ includes a reference to a comp.mail.sendmail posting using only 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 <> From: Homme Bitter (H.Bitter at syntegra dotte nl) Subject: Solution for copying all mail to archive Newsgroups: comp.mail.sendmail View: (This is the only article in this thread) | Original Format Date: 1997/06/20 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. Solution: 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 ! ). MAILER(`procmail')dnl LOCAL_RULE_0 R$*<@$*.procmail>$* $1@<$2>$3 map back of procmail copy LOCAL_RULE_0 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: :0 c: /var/mail/archive 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. Known problems: 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. Homme Also see this message: From: Per Hedeland ( Subject: Re: Using procmail to archive outbound fails - buildaddr: no user Newsgroups: comp.mail.sendmail View this article only Date: 2002-04-13 03:30:06 PST In article <> Harry Putnam <> writes: > > MAILER(`procmail')dnl > LOCAL_RULE_0 > R$*<@$*.procmail>$* $1@<$2>$3 map back of procmail copy > LOCAL_RULE_0 > 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 and generated You *didn't* get the tabs right - it should be like this (no need for multiple LOCAL_RULE_0 directives), where I have used <TAB> instead of actual tab(s): LOCAL_RULE_0 R$*<@$*.procmail>$*<TAB>$1@<$2>$3<TAB>map back of procmail copy R$*<@$+>$*<TAB>$#procmail $@/etc/procmailrc $:$1@$2procmail$3<TAB>send all external mail to procmail Btw, it's probably better to do this with a milter these days. --Per Hedeland Here is the entire thread