Configure Sendmail Client for Auth SMTP

From SWCP Support Wiki
Jump to navigationJump to search

Sendmail

If you are running your own Sendmail mail server on a non-SWCP internet connection, you may find it's difficult to send outgoing mail because your ISP blocks port 25 and/or requires Authenticated SMTP to send. You need to have your sendmail submit mail to mail.swcp.com (or whatever your outgoing SMTP server is) using Authentication, via port 587. Here is the basic idea for how to do it. The particulars of Sendmail configuration are different accross different platforms (even accross different Linux distros), so season this to taste based on your local system.

The config listed here will set up SMTP Authentication, using STARTTLS for encryption, and tell it to use port 587 instead of port 25. This information is only good for sendmail. If you are using Postfix or Qmail or Exim, you will have to find other incantations (google for "authenticated SMTP Postfix" for example). If you are using Exchange Server, this can be done, but I don't know the magic.

 1. Change directory to where your sendmail configuration files (sendmail.mc and sendmail.cf)
    are located, usually /etc/mail/.
 
 2. Create a safe subdirectory (suggested name auth/):
    # mkdir auth
    # chmod 700 auth
 
 3. Create a file with your authentication information (suggested filename: auth/client-info).
    Substitute your outgoing mail server name if it's not mail.swcp.com.  Substitute your account's
    username and password for USERNAME and PASSWORD.
 
        AuthInfo:mail.swcp.com: "U:USERNAME" "P:PASSWORD"
 
 4. Generate the authentication database and make both files readable only by root:
 
   # cd auth
   # makemap hash client-info < client-info
   # chmod 600 client-info*
   # cd ..
 
 5. Add the following lines to your sendmail.mc file (again substitute your outgoing server name):
 
   define(`SMART_HOST',`[mail.swcp.com]')dnl
   define(`RELAY_MAILER_ARGS', `TCP $h 587')
   define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
   FEATURE(`authinfo',`hash /etc/mail/auth/client-info')dnl
        
 6. Generate sendmail.cf (this may differ depending on your OS):
 
   # m4 sendmail.mc > sendmail.cf
        
 7. Restart the sendmail daemon, e.g., (this depends on your OS):
 
   # kill -HUP `cat /var/run/sendmail.pid`   (old-school)   -OR-
   # make restart                            (FreeBSD)      -OR-
   # /etc/init.d/sendmail reload             (debian Linux)

See Also