email archiving
by Shane B. Milburn
Shane is the lead systems administrator for the Modis
Characterization Support Team (MCST), a subtask on NASA's MODIS
project.
msgidruleset.m4 I'm not claiming to be an expert on writing sendmail rulesets. But with the recent thread on "Email Monitoring" going across the <sage-members> mailing list, I thought I'd share my solution. There may be a more efficient way to do this, but this seems to work for me. Listing 1 shows my modified version of Harker's configuration.
1 VERSIONID(`msgidruleset.m4')
Here's a description of what msgidruleset.m4 does. The first eight lines will insert the text between the quotes into your sendmail.cf file as comments. Lines 2530 define a new mailer named copymail. This definition reinvokes sendmail with the original recipients ($u) and an additional recipient named copyuser@$j.NOCOPY. While this does cause additional load on the server, in my case it was not enough of a load to cause concern. Now let's look at the rest of the m4 file. Lines 910 will print an error message if in your site-config.mc file you try to declare before smtp. The next two lines tell sendmail to declare a local class. The LOCAL_NET_CONFIG line forwards nonlocal network stuff to SMART_HOST. The LOCAL_RULE_0 statement is used to introduce new parsing rules. This is where you place any custom delivery agents and parsing rules you have defined. In Listing 1, the custom parsing rules are lines 1823. Installation In order to install this, you need to place msgidruleset.m4 into a file called msgidruleset.m4 in the sendmail-8.9.3/cf/feature/ directory. Don't forget that there are tabs between the first and second entries on lines 1823. (If you do forget, sendmail will remind you.) Now add the following line to your site-config.mc file. FEATURE(msgidruleset) Here is what my site-config.mc file looks like.
VERSIONID(`@(#)mcst-config.mc Shane B. Milburn 04/21/1999')
After you create your site-config.mc file, use the m4 program to generate your sendmail.cf file. In /usr/local/src/sendmail-8.9.3/cf/cf you would use m4 ../m4/cf.m4 site-config.mc > sendmail.cf. This would create a sendmail.cf in the cf directory. You can either move this file into /etc/mail/ or invoke sendmail with the -C option to test. (Note: If you use the -C option for testing, make sure you change line 30 in Listing 1 to A=/usr/lib/sendmail -C/path/to/sendmail.cf copyuser@$j.NOCOPY $u. Otherwise, when you reinvoke sendmail it uses /etc/mail/sendmail.cf, which does not have the .NOCOPY parsing rules and will bounce your message.) Testing To test this new configuration, invoke sendmail from the command line. The first test takes a username mkephart and passes it to ruleset 3 and then 0. This causes the username to be rewritten to mkephart@mcst.gsfc.nasa.gov.NOCOPY. Even though it's not shown, line 30 in msgidruleset.m4 also causes a second address copyuser@mcst.gsfc.nasa.gov.NOCOPY to be passed back to sendmail.
# /usr/lib/sendmail -C/usr/local/src/sendmail-8.9.3/cf/cf/ Continuing with the testing, let's pass mkephart@mcst.gsfc.nasa.gov.NOCOPY to rulesets 3,0. You can see that this time the address is eventually passed to ruleset 98, which is lines 1823. Notice that the .NOCOPY tag gets stripped off, and the email message is delivered to mkephart. Same as before, this is also happening for copyuser@mcst.gsfc.nasa.gov.NOCOPY and being delivered via mail.local to copyuser.
> 3,0 mkephart@mcst.gsfc.nasa.gov.NOCOPY
Everything looks like it works, but let's try sending an email message and make sure it actually works before we put this sendmail.cf file into production.
# /usr/lib/sendmail -C/path/to/sendmail.cf -t
Checking my Netcom account, I see that I did receive the email. If I cat /var/mail/copyuser, it contains a copy of the message. Now that you're convinced it works, you can install your new sendmail.cf into /etc/mail/sendmail.cf and restart sendmail. There is a catch to all of this logging. Depending on the amount of mail that goes through the system, /var/mail/copyuser can get quite large. Since I needed to make an archive through which a user must parse, it made sense to rotate the file daily. This allowed the user to grep a particular day's email rather than a week's or a month's worth of email. At the end of the week I stared the files into a weekending.MMDDYYYY.tar file and wrote it to 8mm tape. Before you implement an email archive, make sure your company has a policy about privacy issues and who actually owns the email sent to/from your server. Reference [1] <http://www.harker.com/sendmail/copyuser.html> Other Resources Costales, Bryan and Eric Allman, Sendmail, 2nd ed. Sebastopol, CA: O'Reilly & Associates, 1997. Newsgroup: <comp.mail.sendmail>
Config file downloads: <http://mcst.gsfc.nasa.gov/sendmail/>
|
|
Last changed: 22 Nov. 1999 mc |
|