How to Use Google SMTP Relay with Sendmail

Check to see if TLS is enabled:
# sendmail -d0.1 -bv root


Make a certs directory:
# mkdir /ect/mail/certs
# cd /ect/mail/certs


Create SSL certificates:
# openssl req -new -x509 -keyout cakey.pem -out cacert.pem -days 3650
// password, all left default
# openssl req -nodes -new -x509 -keyout sendmail.pem -out sendmail.pem -days 3650


copy certificates from system to mail directory:
# cp /etc/pki/tls/certs/ca-bundle.crt /etc/mail/certs


Stop sendmail services prior to making changes:
# service sendmail stop


Create authentication table:
# vim /etc/mail/authinfo
----
AuthInfo:smtp.gmail.com "U:root" "I:admin@cafecenter.com" "P:Katie2000" "M:PLAIN"
AuthInfo:smtp.gmail.com:587 "U:root" "I:admin@cafecenter.com" "P:Katie2000" "M:PLAIN"
----
makemap hash /etc/mail/authinfo < /etc/mail/authinfo


Defined "SMART_HOST" information:
# vim /etc/mail/sendmail.mc
---
FEATURE(`authinfo',`hash /etc/mail/authinfo.db')dnl
define(`SMART_HOST', `smtp.gmail.com')dnl
define(`RELAY_MAILER_ARGS', `TCP $h 587')
define(`ESMTP_MAILER_ARGS', `TCP $h 587')
define(`CERT_DIR', `/etc/mail/certs')
define(`confCACERT_PATH', `CERT_DIR')
define(`confCACERT', `CERT_DIR/ca-bundle.crt')
define(`confCRL', `CERT_DIR/ca-bundle.crt')
define(`confSERVER_CERT', `CERT_DIR/sendmail.pem')
define(`confSERVER_KEY', `CERT_DIR/sendmail.pem')
define(`confCLIENT_CERT', `CERT_DIR/sendmail.pem')
define(`confCLIENT_KEY', `CERT_DIR/sendmail.pem')
---
# m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf


Start the email service:
# service sendmail start


DONE!


php /home/www/kimconnect/testmail.php

Leave a Reply

Your email address will not be published. Required fields are marked *