Sending email via Gmail relay through sendmail
From Notes_Wiki
<yambe:breadcrumb>Sendmail_server_configuration|Sendmail server configuration</yambe:breadcrumb>
Sending email via Gmail relay through sendmail
To send email via Gmail relay through sendmail use:
- Configure gmail to use less secure apps using:
- Login into Gmail account and go to Settings -> Accounts -> Google Account Settings
- In "Google Account Settings" go to Sign-in and Security.
- In Sign-in and security change "Allow less secure apps:" to ON
- edit /etc/mail/sendmail.mc and add following lines after commented SMART_HOST line
- 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_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
- FEATURE(`authinfo',`hash /etc/mail/auth/client-info')dnl
- create /etc/mail/auth and /etc/mail/auth/client-info with following contents:
- AuthInfo:smtp.gmail.com "U:root" "I:<gmail-email-address>" "P:<gmail-password>" "M:PLAIN"
- AuthInfo:smtp.gmail.com:587 "U:root" "I:<gmail-email-address>" "<gmail-password>" "M:PLAIN"
- chmod 700 /etc/mail/auth
- chmod 600 /etc/mail/auth/client-info
- cd /etc/mail/auth
- makemap hash client-info.db < client-info
- cd /etc/mail
- make
- service sendmail restart
- echo "Test email using sendmail" | mail -s "Gmail relay test" saurabh@sbarjatiya.com
For debugging refer to /var/log/maillog. In /var/log/maillog look at value of ctladdr such as 'ctladdr=<saurabh@localhost.localdomain>' to find out which local user will get the bounce message back. Then look for /var/mail/<username> file. You can also use mail command from given user and read the bounce messages to understand the issue being faced.
<yambe:breadcrumb>Sendmail_server_configuration|Sendmail server configuration</yambe:breadcrumb>