Relay email via SMTP provider using sendmail

The below is specific to CentOS-5.4 and may work similarly with other distros.

  • Additional packages required if not installed already:

    sendmail-cf
    m4
    make
    cyrus-sasl-plain

  • Edit ”/etc/mail/sendmail.mc”:
    define(`SMART_HOST', `{smtprelay.domain.tld}')dnl
    FEATURE(`authinfo',`hash -o /etc/mail/authinfo.db')dnl
  • Create file ”/etc/mail/authinfo” with below contents and chmod 640:
    AuthInfo:smtprelay.domain.tld "U:{username}" "P:{password}" "M:PLAIN"
  • Update the sendmail conf and db hashes:
    cd /etc/mail
    make
  • Restart sendmail for the new configs to pick up.
  • Now mails sent to localhost is relayed via your SMTP provider.
Comment