This tutorial will help you to configure Sendmail to relay email through external smtp servers like Gmail, Amazon SES, Mailchimp, Mandrill etc. In this tutorial we are suing Gmail SMTP server to relay emails from sendmail server.
1. Create Auth File
First create directory for storing authentication files.
$ sudo mkdir /etc/mail/auth $ sudo chmod 700 /etc/mail/auth
Now create a auth file with any name like smtp-auth and add following content. Replace the above email with your gmail or google apps email.
$ sudo vi /etc/mail/auth/smtp-auth
AuthInfo: "U:root" "I:user@gmail.com" "P:PASSWORD"
Now create a hash map file of above created auth file.
$ makemap hash /etc/mail/auth/smtp-auth < /etc/mail/auth/smtp-auth
2. Configure Sendmail with SMART_HOST
Now add following configuration lines into your sendmail.mc configuration file below "MAILER" definition.
define(`SMART_HOST',`[smtp.gmail.com]')dnl define(`RELAY_MAILER_ARGS', `TCP $h 587')dnl define(`ESMTP_MAILER_ARGS', `TCP $h 587')dnl define(`confAUTH_OPTIONS', `A p')dnl TRUST_AUTH_MECH(`EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl FEATURE(`authinfo',`hash -o /etc/mail/authinfo/smtp-auth.db')dnl
In the next step we will need to re-build sendmail's configuration. To do that execute:
# make -C /etc/mail
3. Verify Setup
After completing all above configuration, reload sendmail service.
$ sudo service sendmail reload
Now send a test email verify everything is working fine.
$ echo "Test Email" | mail -s "Subject Here" recipient@example.com
Thanks for Visit Here
Comments
Post a Comment