Setting up SMTP AUTH under RedHat 7.3 (Linux)

I recently had to configure a Linux machine to require SMTP AUTH so that we could test a new product at Codonics. So I wanted to provide a little guidance and some insight that I gained while working on this task.

The requirement was “basic” SMTP AUTH… so PLAIN/LOGIN functionality, no need for TLS, and use the existing user accounts on the linux machine. Local email needs to still function (mail from cmd line) but anything from a “remote” user would require a username/password to be verified before allowing the machine to send the email.

1) need to allow sendmail to talk to more than just localhost (allow network connections)
– firewall (open ports, or disable for testing)
– “dnl DAEMON_OPTIONS(`Port=smtp,Addr=, Name=MTA’)” line in the instead of “DAEMON_OPTIONS(`Port=smtp,Addr=, Name=MTA’)” …. adding the dnl in front of the command basically comments it out.

2) need to install from source (for our RedHat 7.3 machine, I used these versions):
– cyrus-sasl (v1.5.24)
– sendmail (8.11.6)
* these versions were selected because they matched the rpms/version that were already installed on machine. I needed to be rebuild to provide support for PLAIN and LOGIN AUTH methods… which I understand are not typically available via RPMs.

3) Important lines in the
define(`confAUTH_OPTIONS’, `A’)dnl
make sure that none of these have a dnl in front of them… that would cause them to be ignored (considered comments).

4) There needs to be a file: /usr/lib/sasl/Sendmail.conf (note the upper-case S in filename) with the following line (only line):
– “pwcheck_method: PAM”

5) Not sure if this is actually required, but during my travels, I found that I need the file /etc/sasldb to exist and it can only be read/writeable by root so:
– touch /etc/sasldb (to create it if necessary)
– chown root:root /etc/sasldb (to change it to owner/group root)
– chmod 600 /etc/sasldb (to ensure that only root user can read/write file)

6) I did confirm that these changes will only require AUTH on connections from external mail clients (doesn’t affect mail cmd-line on the host).

7) If you want to test via “telnet host 25” the sequence of events would be:
-> EHLO hostname (doesn’t matter what you use as hostname)
<- 334 VXNlcm5hbWU6 -> anNueWRlcg== (Base64 encoded username, ie: jsnyder thru the base64 encoder)
<- 334 UGFzc3dvcmQ6 -> dGVzdGluZw== (Base64 encoded password for username above)
<- 235 2.0.0 OK Authenticated (this is a good sign... no need to continue) -> QUIT

Useful commands:
– m4 /etc/mail/ > /etc/ (converts the file into the necessary for sendmail to use)

– sendmail -d0.1 -bv root (shows if SASL support is available in sendmail in the list of “Compiled with:” items)

– sendmail -d0.20 -bv (shows location it is expecting … “Def Conf file:” line).

– sendmail -O LogLevel=33 -bs (runs a quick instance of sendmail with logging turned up to level 33, and then you can enter “ehlo localhost” and it should give you back the options for the server… should include the line: “250-AUTH LOGIN PLAIN” when everything is configured correctly).

Helpful Links:

Sendmail downloads:

Base64 Encode/Decoder:

Content of my “” file for comparison:

dnl This is the sendmail macro config file. If you make changes to this file,
dnl you need the sendmail-cf rpm installed and then have to generate a
dnl new /etc/ by running the following command:
dnl m4 /etc/mail/ > /etc/
VERSIONID(`linux setup for Red Hat Linux')dnl
dnl Uncomment and edit the following line if your mail needs to be sent out
dnl through an external mail server:
dnl define(`SMART_HOST',`smtp.your.provider')
define(`LOCAL_RELAY', `')
define(`MAIL_HUB', `')
define(`SMART_HOST', `')
define(`confTO_CONNECT', `1m')dnl
define(`ALIAS_FILE', `/etc/aliases')dnl
dnl define(`STATUS_FILE', `/etc/mail/statistics')dnl
define(`UUCP_MAILER_MAX', `2000000')dnl
define(`confUSERDB_SPEC', `/etc/mail/userdb.db')dnl
define(`confPRIVACY_FLAGS', `authwarnings,novrfy,noexpn,restrictqrun')dnl
define(`confAUTH_OPTIONS', `A')dnl
dnl define(`confTO_QUEUEWARN', `4h')dnl
dnl define(`confTO_QUEUERETURN', `5d')dnl
dnl define(`confQUEUE_LA', `12')dnl
dnl define(`confREFUSE_LA', `18')dnl
dnl FEATURE(delay_checks)dnl
FEATURE(`mailertable',`hash -o /etc/mail/mailertable.db')dnl
FEATURE(`virtusertable',`hash -o /etc/mail/virtusertable.db')dnl
dnl The '-t' option will retry delivery if e.g. the user runs over his quota.
FEATURE(local_procmail,`',`procmail -t -Y -a $h -d $u')dnl
FEATURE(`access_db',`hash -o /etc/mail/access.db')dnl
dnl This changes sendmail to only listen on the loopback device
dnl and not on any other network devices. Comment this out if you want
dnl to accept email over the network.
dnl DAEMON_OPTIONS(`Port=smtp,Addr=, Name=MTA')
dnl NOTE: binding both IPv4 and IPv6 daemon to the same port requires
dnl a kernel patch
dnl DAEMON_OPTIONS(`port=smtp,Addr=::1, Name=MTA-v6, Family=inet6')
dnl We strongly recommend to comment this one out if you want to protect
dnl yourself from spam. However, the laptop and users on computers that do
dnl not have 24x7 DNS do need this.
dnl FEATURE(`relay_based_on_MX')dnl

Problems installing Perl modules under Redhat8/Redhat9

I had another friend get bitten by this *feature*, and felt it was worthy of a note on this site.

: “Note for Perl 5.8 Users (incl Red Hat 8)

Redhat 8 and 9 changed the default LANG to something with utf8 and this causes all kinds of problems with installing various modules and software. So the fix is to set the environment LANG=en_US before going to into CPAN.

Just do “export LANG=en_US” on the command line, and then install the module you need. You probably want to consider installing this into something like /etc/profile, or other global environment area so that it is selected the default for all users.