1. Install prerequisites
|
yum install sendmail mailutils sendmail-bin |
2. Create Gmail Authentication file
|
mkdir -m 700 /etc/mail/authinfo/ cd /etc/mail/authinfo/ |
nano gmail-auth
|
AuthInfo: "U:root" "I:YOUR GMAIL EMAIL ADDRESS" "P:YOUR PASSWORD" |
Replace the above email with your gmail or google apps email.
In the next step we will need to create a hash map for the above authentication file:
|
makemap hash gmail-auth < gmail-auth |
Put bellow lines into your sendmail.mc configuration file right above first «MAILER» definition 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_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/gmail-auth.db')dnl |
Do not put the above lines on the top of your sendmail.mc configuration file !
In the next step we will need to re-build sendmail’s configuration. To do that execute:
Reload sendmail service:
|
/etc/init.d/sendmail reload |
and you are done.
4. Configuration test
Now you can send an email from your command line using mail command:
|
$ echo "Just testing my sendmail gmail relay" | mail -s "Sendmail gmail Relay" my-email@my-domain.com |
If you will experience substitutional delays after executing the above command to most likely cause is that you have not configured your host with FQDN. Check your logs for a warning: