Using virtusertable for Sendmail on Solaris 10 to create a mail sink

Posted by sam Fri, 11 Jun 2010 12:36:00 GMT

If you want your Sendmail instance to accept mails for a nonsense domain and then discard them completely, here is one way of doing it. Another is to use milters. This is documented to death for Linux and the *BSDs, so I thought I’d write down the steps for getting it working under Solaris 10.

This guide assumes that the main *.cf files have always been built through m4, and that the .mc files in /etc/mail/cf/cf are current.

All steps to be performed as root.

Make a backup of your mail configuration, just in case

cd /etc
cp -pr mail mail.bak

Edit the sendmail.mc file to add the virtusertable feature definition.

cd /etc/mail/cf/cf
vi sendmail.mc
...
DOMAIN(`solaris-generic')dnl
FEATURE(`virtusertable')dnl
define(`confFALLBACK_SMARTHOST', `mailhost$?m.$m$.')dnl
...

Build your new sendmail.cf, setup some configuration files, restart sendmail and ensure the SMF-managed service has been been restarted and is marked “online”.

/usr/ccs/bin/make
cd /etc/mail
cp sendmail.cf sendmail.cf.bak
cp /etc/mail/cf/cf/sendmail.cf .
echo "nowhere.com" >> local-host-names
echo "@nowhere.com:    nobody" >> virtusertable
makemap hash /etc/mail/virtusertable < virtusertable
svcadm restart sendmail
svcs -a | grep -i sendmail

Test that it really works as we think it should. You should also try mailing a “real” deliverable domain if you intend this Sendmail instance to do that for normal mail. (You can paste this whole box straight onto the command line and it’ll work)

mail bob@nowhere.com
TEST
.
mail mary@nowhere.com
TEST
.

Finally, we check the logs to ensure everything is working. The important parts to look for are ‘to=/dev/null’ and ‘mailer=file’. Check your spools, too.

grep -i nowhere.com /var/log/syslog

Jun 11 14:05:59 dev sendmail[4472]: [ID 801593 mail.info] o5BD5xto004472: to=bob@nowhere.com, ctladdr=sam (60005/10), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30103, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (o5BD5xsQ004474 Message accepted for delivery)
Jun 11 14:05:59 dev sendmail[4476]: [ID 801593 mail.info] o5BD5xsQ004474: to=/dev/null, ctladdr= (1/0), delay=00:00:00, xdelay=00:00:00, mailer=*file*, pri=30551, dsn=2.0.0, stat=Sent
Jun 11 14:06:18 dev sendmail[4489]: [ID 801593 mail.info] o5BD6Iem004489: to=mary@nowhere.com, ctladdr=sam (60005/10), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30103, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (o5BD6Iru004490 Message accepted for delivery)
Jun 11 14:06:18 dev sendmail[4491]: [ID 801593 mail.info] o5BD6Iru004490: to=/dev/null, ctladdr= (1/0), delay=00:00:00, xdelay=00:00:00, mailer=*file*, pri=30553, dsn=2.0.0, stat=Sent