There are a number of ways to implement an Anti-Spam scheme with Sendmail.
I will detail my favorite method, which
is very flexible, easy to administer, easy to install, easy to understand.
How this works
Originate locally, terminate remotely
Originate locally, terminate locally
Originate remotely, terminate
locally
If the host is listed in /etc/mxlist, no restrictions are imposed. Note that a failed match will not generate an immediate error. Instead, it will appear as though the mail has been accepted and delivered. However, the mail will later be bounced back to the sender, or if the sender is invalid, dumped to postmaster. I plan to work on the rules a bit to make it an immediate failure, to accommodate servers with already high volumes. If no host name is specified in the MAIL FROM, the local domain is assumed.
For example, host.com is allowed to relay through the mail hub:
MAIL FROM: user@host.com
250 user@host.com... Sender ok
RCPT TO: user@otherhost.com
250 user@otherhost.com... Recipient ok
The file /etc/spamlist contains specific hosts which need the special message. Personally, I have not used it.
1. If you need
to upgrade, do so: ftp://ftp.sendmail.org/pub/sendmail.8.8.8.tar.gz
Note that if you have Sendmail 8.8.7, it is strongly advised
to upgrade. A bug
exists in version 8.8.7 when used with these rules, deferred delivery mode,
etc.
2. The M4 utility.
This is fairly standard on most UNIX systems, and is required to
to generate a useable sendmail.cf file. In fact, this must be present
to do anything
at all with this. ftp://gatekeeper.dec.com:/pub/GNU/m4-1.4.tar.gz
3. The drop-in rules
to implement the Relay Method:
LOCAL_CONFIG
4.
Create the CF file, with M4, and your newly-created MC file:
% m4 file.mc > file.cf
5.
Create /etc/mxlist, and /etc/spamlist. These files are normal text
files, one host per line:
% touch /etc/mxlist /etc/spamlist
6.
Add the required entries to /etc/mxlist. Some of the required
hosts that must be there are:
localhost
machine's name
machine's FQDN
7. Add any other hosts that are allowed to relay through your host.
8.
Install the new CF file.
##### @(#)local.m4 8.23 (Berkeley) 5/31/96 #####
Mlocal, P=/usr/bin/procmail,
F=lsDFMAw5:/|@qSPfhn9, S=10/30, R=20/40,
T=DNS/RFC822/X-Unix,
A=procmail -Y -a $h -d $u
Mprog, P=/bin/sh,
F=lsDFMoqeu9, S=10/30, R=20/40, D=$z:/,
T=X-Unix,
A=sh -c $u
for i in `ls -CF1`
do
if [ -f $i.forward ] ; then
cat $i.forward | cut -f2
-d @ >> ~/forwards
fi
done
/etc/mxlist is a simple text file, one host per line
Save your old sendmail.cf in case this makes everything break- in a
large ISP-type environment, everything will break until you have
all client domains listed.
Happy Anti-Spamming!