Configuring Sendmail to use SMTP
Configuring Sendmail to use SMTP AUTH

This document describes how to configure Sendmail to use SMTP AUTH under FreeBSD.

These instructions apply to the version of Sendmail included in the FreeBSD base distribution. If you're using the Sendmail port, these steps won't work for you. To compile the Sendmail port with SASL2, just build it with make install -DSENDMAIL_WITH_SASL2.

Applies To:

Install the Sendmail Source Distribution:

The first step is to make sure the necessary source distributions are installed. You'll need the contrib, lib and usbin source packages. If you've already got those installed, skip ahead and install Cyrus-SASL. Otherwise, follow the steps below:

# su
    (enter your root password)
# /stand/sysinstall

Choose Configure, then Distributions, then src. Select contrib, lib and usbin, then press OK and install the packages.

Configure Distributions src contrib, lib and usbin

Install Cyrus-SASL 2:

Make sure you've updated your ports collection recently, then do this:

# cd /usr/ports/security/cyrus-sasl2
# make install clean

A menu will appear. The default selections are fine. Just hit OK.

Hit OK

Recompile Sendmail:

Edit /etc/make.conf (create it if it doesn't already exist), and add these lines:

SENDMAIL_CFLAGS+=   -I/usr/local/include -DSASL=2
SENDMAIL_LDFLAGS+=  -L/usr/local/lib
SENDMAIL_LDADD+=    -lsasl2

And now we'll recompile Sendmail:

# cd /usr/src/lib/libsm
# make cleandir
# make obj
# make

# cd /usr/src/lib/libsmutil
# make cleandir
# make obj
# make

# cd /usr/src/usr.sbin/sendmail
# make cleandir
# make obj
# make
# make install

Configure Sendmail:

Edit /usr/local/lib/sasl2/Sendmail.conf (create it if it doesn't already exist) and add this line:

pwcheck_method: saslauthd

Next, edit your Sendmail configuration file. Your Sendmail config file is probably /etc/mail/[hostname].mc, where "[hostname]" is the host name of your computer. If that's not the case, then you can just edit /etc/mail/freebsd.mc. Add the following lines to this file:

dnl SASL Options
define(`confRUN_AS_USER',`root:mail')dnl
TRUST_AUTH_MECH(`DIGEST-MD5 CRAM-MD5 LOGIN')dnl
define(`confAUTH_MECHANISMS',`DIGEST-MD5 CRAM-MD5 LOGIN')dnl
define(`confDONT_BLAME_SENDMAIL',`GroupReadableSASLDBFile')dnl

And to put the configuration changes into effect:

# cd /etc/mail
# make
# cp [hostname].cf sendmail.cf
    (replace [hostname] with the name of your Sendmail config file)

Add a SASL user:

You'll need to add all authenticating SMTP users to the /usr/local/etc/sasldb2 file. These users must match up with user accounts on the system, although their passwords can be different. You can add a user like so:

# /usr/local/sbin/saslpasswd2 [username]
    (you will then be prompted for the password for this user)

One last command:

# killall -HUP sendmail

And we're done! You should now have a working installation of Sendmail with support for SMTP authentication. Enjoy!








Previous page: doc.nettools.ru/UnixMain page: www.nettools.ru