Sendmail

Routing all outgoing mails via the outgoing smarthost:

  1. Ensure the IP address is added as an authorized smarthost (without authentication)
  2. Ensure the outgoing user has correct limits set matching your traffic volumes
  3. Update your configuration:
    1. For this you have to edit /etc/sendmail.mc and add the following lines at the top under the "pert(-1)dnl" line:
    2. define(`RELAY_MAILER_ARGS', `TCP $h 587')dnl
      define(`SMART_HOST', `[SMART.HOST.TLD]')dnl

    3. Run "sendmailconfig" to use this new configuration
    4. This will automatically re-start sendmail

Alternative Configuration with username authentication (un-tested)

  1. Change directory to where your sendmail configuration files (sendmail.mc and sendmail.cf) are located, usually /etc/mail/
  2. Create a safe sub-directory (suggested name auth/):
  3. # mkdir auth
    # chmod 700 auth
  4. Create a file with your authentication information (suggested filename: auth/client-info)
  5. AuthInfo:SMARTHOST: "U:USERNAME" "P:PASSWORD"
  6. Generate the authentication database and make both files readable only by root:
  7. # cd auth
    # makemap hash client-info < client-info
    # chmod 600 client-info*
    # cd ..
  8. Add the following lines to your sendmail.mc file
  9. define(`SMART_HOST',`[SMARTHOST]')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
    
  10. Generate sendmail.cf
  11. # m4 sendmail.mc > sendmail.cf
  12. Restart the sendmail daemon
  13. # kill -HUP `cat /var/run/sendmail.pid` (old-school) -OR-
    # make restart (FreeBSD) -OR-
    # /etc/init.d/sendmail reload (debian Linux)
  14. SMARTHOST should be replaced with your SMTP hostname