handbook-smtp-auth
20.10 SMTP Authentication
*Written by James Gorham. *
Having SMTP Authentication in place on your mail server has a number of benefits. SMTP Authentication can add another layer of security to sendmail , and has the benefit of giving mobile users who switch hosts the ability to use the same mail server without the need to reconfigure their mail client settings each time.
Install
security/cyrus-saslfrom the ports. You can find this port insecurity/cyrus-sasl.security/cyrus-saslhas a number of compile time options to choose from and, for the method we will be using here, make sure to select thepwcheckoption.After installing
security/cyrus-sasl, edit/usr/local/lib/sasl/Sendmail.conf(or create it if it does not exist) and add the following line:pwcheck_method: passwd
This method will enable sendmail to authenticate against your DragonFly
passwddatabase. This saves the trouble of creating a new set of usernames and passwords for each user that needs to use SMTP authentication, and keeps the login and mail password the same.Now edit
/etc/make.confand add the following lines:SENDMAIL_CFLAGS=-I/usr/pkg/include/sasl -DSASL SENDMAIL_LDFLAGS=-L/usr/pkg/lib SENDMAIL_LDADD=-lsasl2These lines will give sendmail the proper configuration options for linking to
cyrus-saslat compile time. Make sure thatcyrus-saslhas been installed before recompiling sendmail .Recompile sendmail by executing the following commands:
# cd /usr/src/usr.sbin/sendmail # make cleandir # make obj # make # make installThe compile of sendmail should not have any problems if
/usr/srchas not been changed extensively and the shared libraries it needs are available.After sendmail has been compiled and reinstalled, edit your
/etc/mail/freebsd.mcfile (or whichever file you use as your.mcfile. Many administrators choose to use the output from hostname(1) as the.mcfile for uniqueness). Add these lines to it:dnl set SASL options
TRUST_AUTH_MECH(`GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN')dnl
define(
confAUTH_MECHANISMS',GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN')dnldefine(
confDEF_AUTH_INFO',/etc/mail/auth-info')dnlThese options configure the different methods available to sendmail for authenticating users. If you would like to use a method other than pwcheck , please see the included documentation.
Finally, run make(1) while in
/etc/mail. That will run your new.mcfile and create a.cffile namedfreebsd.cf(or whatever name you have used for your.mcfile). Then use the commandmake install restart, which will copy the file tosendmail.cf, and will properly restart sendmail . For more information about this process, you should refer to/etc/mail/Makefile.
If all has gone correctly, you should be able to enter your login information into the mail client and send a test message. For further investigation, set the LogLevel of sendmail to 13 and watch /var/log/maillog for any errors.
You may wish to add the following lines to /etc/rc.conf so this service will be available after every system boot:
sasl_pwcheck_enable="YES"
sasl_pwcheck_program="/usr/local/sbin/pwcheck"
This will ensure the initialization of SMTP_AUTH upon system boot.
For more information, please see the sendmail page regarding SMTP authentication.
CategoryHandbook
CategoryHandbook-email