NOTE. As of October 2010, I use Postfix on Mac OS X, which is hilariously simpler to configure for this same task than sendmail. These instructions should still work, but I certainly won’t be updating them if I can help it.
Install SASL, which sendmail needs to authenticate at the SMTP relay.
portinstall security/cyrus-sasl2If you don’t already have the
srcdistributions, install them now viasysinstall(8).Recompile sendmail with SASL.
cat >> /etc/make.conf SENDMAIL_CFLAGS=-I/usr/local/include/sasl -DSASL SENDMAIL_LDFLAGS=-L/usr/local/lib SENDMAIL_LDADD=-lsasl2 ^D cd /usr/src/lib/libsmutil make cleandir && make obj && make cd /usr/src/lib/libsm make cleandir && make obj && make cd /usr/src/usr.sbin/sendmail make cleandir && make obj && make && make installIf you want to allow a subnet to relay mail through this machine, add it to the access database.
cat >> /etc/mail/access Connect:192.168 RELAY ^D makemap hash /etc/mail/access < /etc/mail/accessRecord the credentials sendmail will use to authenticate at the SMTP relay. Replace
mail.panix.comwith your SMTP relay’s hostname;cfm@panix.com, your username;*****, your password.cat > /etc/mail/authinfo AuthInfo:mail.panix.com "U:cfm@panix.com" "I:cfm@panix.com" "P:*****" "M:PLAIN" ^D chmod 600 /etc/mail/authinfo makemap hash /etc/mail/authinfo < /etc/mail/authinfoMake sure sendmail has created the proper configuration files.
cd /etc/mail make all installConfigure relaying. Replace
camphorwith your machine’s hostname;mail.panix.comwith your SMTP relay’s hostname;panix.comwith the domain of your e-mail address.vim /etc/mail/camphor.mc # before "MAILER" lines, add: define(`SMART_HOST',`mail.panix.com') define(`RELAY_MAILER_ARGS', `TCP $h 587') define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN') FEATURE(`authinfo',`hash /etc/mail/authinfo') MASQUERADE_AS(`panix.com') FEATURE(`masquerade_envelope')If you intend to submit mail while offline, disable sendmail’s DNS checks and configure it to queue mail by default. Replace
camphorwith your machine’s hostname.vim /etc/mail/camphor.mc # after the lines you added in Step 7, add: FEATURE(`accept_unresolvable_domains') FEATURE(`accept_unqualified_senders') FEATURE(`nocanonify') define(`confDELIVERY_MODE',`deferred') define(`confDIRECT_SUBMISSION_MODIFIERS', `C') define(`confTO_QUEUEWARN', `24h')Build and load the new configuration.
cd /etc/mail make all install restartSend yourself a test message. Replace
cfm@panix.comwith your e-mail address.uname -a | mail -s "uname -a" cfm@panix.comIf you configured queueing in Step 8, tell sendmail to run its queues manually.
sendmail -qf -Ac # clientmqueue sendmail -qf # mqueueCheck the sendmail log.
tail /var/log/maillogIf all has gone well, you’ll see output like this:
May 12 19:31:48 camphor sendmail[87306]: o4CNVmmV087306: from=cfm, size=185, class=0, nrcpts=1, msgid=<201005122331.o4CNVmmV087306@camphor>, relay=cfm@localhost May 12 19:31:48 camphor sm-mta[87307]: o4CNVmTG087307: from=<cfm@camphor>, size=473, class=0, nrcpts=1, msgid=<201005122331.o4CNVmmV087306@camphor>, proto=ESMTP, daemon=IPv4, relay=localhost [127.0.0.1] May 12 19:31:48 camphor sendmail[87306]: o4CNVmmV087306: to=cfm@panix.com, ctladdr=cfm (501/501), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30185, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (o4CNVmTG087307 Message accepted for delivery)