Home Blog Music Papers Photography About Me

Sendmail configuration changes to support SMTP authentication

The Problem

Frontiernet changed their mail server to require authentication on SMTP connections. I need to change sendmail to send auth information when sending mail out through their server (since they block direct SMTP connections from DSL). Sendmail's configuration files are notoriously cryptic.

The Solution

These are the things I had to change to get it to work (under the SuSE 9.1 sendmail installation):

Creating the Auth Files

First, create the file /etc/mail/default-auth-info:

root
<username>@frontiernet.net
<password>
smtp.frontiernet.net

The first line is a sendmail "trusted user", and it seems like it should always be 'root'. The next line is the Frontiernet login (same as POP3). Frontier seems to require the full email address. The next is the Frontiernet password to use, and the last line is the mail server hostname. The file must be owned by root and mode 600 (chmod 600 default-auth-info). This file might not actually be needed (see next), but it doesn't seem to hurt.

Second, put a line in /etc/mail/auth/auth-info as follows:

AuthInfo:smtp.frontiernet.net "U:root" "I:<username>@frontiernet.net" "P:<password>"

substituting your Frontiernet username and password for <username> and <password>. Again, make this owned by root and mode 600.

Editing /etc/sendmail.cf

Now the trickier stuff. Start editing /etc/sendmail.cf. Near the top, with the database definitions (K lines), add the line:

# authinfo list database: contains info for authentication as client
Kauthinfo hash -o /etc/mail/auth/auth-info
Next, add or change the following lines in the options (O line) section:
# list of authentication mechanisms
O AuthMechanisms=LOGIN PLAIN EXTERNAL GSSAPI KERBEROS_V4 DIGEST-MD5 CRAM-MD5

# default authentication information for outgoing connections
O DefaultAuthInfo=/etc/mail/default-auth-info

# SMTP AUTH flags
O AuthOptions=A
In AuthMechanisims, the important one to have is LOGIN, since that's what Frontier uses (I think they might take PLAIN, too).

The authinfo Ruleset

OK, you're almost done here. Search down and find the ruleset Sauthinfo. You need to change it to match the following (commented lines show what I had before making the changes):

N.B.: The left hand side (LHS) and right hand side (RHS) of the rules are separated by TABs, not spaces. Sendmail will barf if you forget this.

######################################################################
###  authinfo: lookup authinfo in the access map
###
###     Parameters:
###             $1: {server_name}
###             $2: {server_addr}
######################################################################
# LHS          | RHS
Sauthinfo
R$*             $: <$(authinfo AuthInfo:$&{server_name} $: ? $)>
R<?>            $: <$(authinfo AuthInfo:$&{server_addr} $: ? $)>
R<?>            $: <$(authinfo AuthInfo: $: ? $)>
R<?>            $@ no                           no authinfo available
R<$*>           $# $1

#R$*            $: $1 $| $>D <$&{server_name}> <?> <! AuthInfo> <>
#R$* $| <?>$*   $: $1 $| $>A <$&{server_addr}> <?> <! AuthInfo> <>
#R$* $| <?>$*   $: $1 $| <$(access AuthInfo: $: ? $)> <>
#R$* $| <?>$*   $@ no                           no authinfo available
#R$* $| <$*> <> $# $2

Rebuilding and Restarting

Now save sendmail.cf. All that's left now is to rebuild databases and restart sendmail. Go back to /etc/mail if you're not there already. Type make, which should rebuild all databases. Watch for something referring to auth-info; that's the important one. Finally, type /etc/init.d/sendmail restart to restart sendmail. Watch for errors here, especially in the config file. (Did you copy the above ruleset and forget to convert the spaces between the LHS and RHS back into tabs?)

If all went well, open your favourite mailer (I use mutt), and send a test message to somewhere off your system. Hopefully it goes through.

If you found this helpful, consider linking to this page or it's parent index, so more people will be able to find it. Of course comments are welcome. Questions, too; though I'm not a sendmail expert. See below for my email information.



Best viewed with any browser Last update: May 25, 2006
$Revision: 1.1 $
$Id: sendmailauth.html,v 1.1 2006/05/26 04:16:01 andrew Exp andrew $
Andrew Turnquist, andrew@turnquist.name (Click to whitelist yourself)