Simple sendmail configuration on OpenBSD

From Wiki

Jump to: navigation, search

Sendmail, otherwise known as "fucking Sendmail!!", is the default MTA on OpenBSD. Sendmail is a dreadful MTA with a horrible track record in security, usability and performance. If you intend to do anything remotely useful with email, save yourself from insanity and replace it with the massively superior Postfix MTA. However, if you just want to perhaps send the output of your cron jobs somewhere convenient, this is just about tolerable.

  • Edit the /etc/mail/aliases file to redirect email which would otherwise go to you or the root user to somewhere else:
#
#       $OpenBSD: aliases,v 1.30 2009/05/20 21:10:06 thib Exp $
#
#  Aliases in this file will NOT be expanded in the header from
#  Mail, but WILL be visible over networks or from /usr/libexec/mail.local.
#
#       >>>>>>>>>>      The program "newaliases" must be run after
#       >> NOTE >>      this file is updated for any changes to
#       >>>>>>>>>>      show through to sendmail.
#

# Basic system aliases -- these MUST be present
MAILER-DAEMON: postmaster
postmaster: root
root: stocksy@example.com
stocksy: stocksy@example.com
  • Rehash the aliases file
# newaliases
  • Try sending yourself some mail:
# echo "Hello, world" | mail -s "Hi" stocksy@example.com ; tail -f /var/log/maillog

Feb 25 21:10:36 fw sendmail[6242]: p1PLAZL4006242: to=stocksy@example.com, ctladdr=stocksy (1000/10), delay=00:00:01, xdelay=00:00:00, mailer=relay, pri=30047, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (p1PLAapA021970 Message accepted for delivery)
Feb 25 21:10:36 fw sm-mta[27317]: p1PLAapA021970: SYSERR(root): MX list for example.com. points back to fw.spruce.toastputer.net
Feb 25 21:10:36 fw sm-mta[27317]: p1PLAapA021970: to=<stocksy@example.com>, ctladdr=<stocksy@fw.spruce.toastputer.net> (1000/10), delay=00:00:00, xdelay=00:00:00, mailer=esmtp, pri=30365, relay=example.com., dsn=5.3.5, stat=Local configuration error
Feb 25 21:10:36 fw sm-mta[27317]: p1PLAapA021970: p1PLAapA027317: DSN: Local configuration error
Feb 25 21:10:36 fw sm-mta[27317]: p1PLAapA027317: to=<stocksy@fw.spruce.toastputer.net>, delay=00:00:00, xdelay=00:00:00, mailer=local, pri=61389, dsn=2.0.0, stat=Sent
Feb 25 21:10:36 fw sm-mta[27317]: p1PLAapA027317: to=stocksy@example.com, delay=00:00:00, xdelay=00:00:00, mailer=esmtp, pri=61389, relay=example.com., dsn=5.3.5, stat=Local configuration error
Feb 25 21:10:36 fw sm-mta[27317]: p1PLAapA027317: p1PLAapB027317: return to sender: Local configuration error
Feb 25 21:10:37 fw sm-mta[27317]: p1PLAapB027317: to=stocksy@example.com, delay=00:00:01, xdelay=00:00:00, mailer=esmtp, pri=32413, relay=example.com., dsn=5.3.5, stat=Local configuration error
Feb 25 21:10:37 fw sm-mta[27317]: p1PLAapA027317: Losing ./qfp1PLAapA027317: savemail panic
Feb 25 21:10:37 fw sm-mta[27317]: p1PLAapA027317: SYSERR(root): savemail: cannot save rejected email anywhere
  • It doesn't work! What a piece of crap! The MX record for my domain most certainly does not point anywhere near this system. Well, let's fudge it. Specify a smarthost:
# cd /usr/share/sendmail/cf
# vi openbsd-submit.mc

### snipsnipsnip ###
define(`_USE_DECNET_SYNTAX_', `1')dnl support DECnet
define(`confTIME_ZONE', `USE_TZ')dnl
define(`confBIND_OPTS', `WorkAroundBrokenAAAA')dnl
define(`confDONT_INIT_GROUPS', `True')dnl
define(`confCT_FILE', `-o MAIL_SETTINGS_DIR`'trusted-users')dnl
define(`SMART_HOST', `mx.toastputer.net')dnl
#                    HERE ^^^^^^^^^^^^^^ HERE
### snipsnipsnip ###
  • Create the .cf file and copy it in to place
# make openbsd-submit.cf
# cp openbsd-submit.cf /etc/mail/submit.cf
  • Restart sendmail to pick up the changes:
# kill -HUP `head -1 /var/run/sendmail.pid`
  • Try again:
# echo "Hello, world" | mail -s "Hi" stocksy@example.com ; tail -f /var/log/maillog

Feb 25 21:47:45 fw sendmail[29102]: p1PLliAn029102: from=stocksy, size=50, class=0, nrcpts=1, msgid=<201102252147.p1PLliAn029102@fw.spruce.toastputer.net>, relay=root@localhost
Feb 25 21:47:45 fw sendmail[29102]: STARTTLS=client, relay=mx.toastputer.net., version=TLSv1/SSLv3, verify=FAIL, cipher=DHE-RSA-AES256-SHA, bits=256/256
Feb 25 21:47:45 fw sendmail[29102]: p1PLliAn029102: to=stocksy@example.com, ctladdr=stocksy (1000/10), delay=00:00:01, xdelay=00:00:00, mailer=relay, pri=30050, relay=mx.toastputer.net. [172.16.0.20], dsn=2.0.0, stat=Sent (Ok: queued as C9693A8065)

What a turd.

Personal tools