Posted On April 1, 2019

How to Use Google SMTP Relay with Sendmail

kimconnect 0 comments
blog.KimConnect.com >> Codes , Linux >> 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:[email protected]" "P:Katie2000" "M:PLAIN"
AuthInfo:smtp.gmail.com:587 "U:root" "I:[email protected]" "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 *

Related Post

How to Enable XRDP Session Sharing

# Edit the xrdp init file sudo vim /etc/xrdp/xrdp.ini # Add this at the bottom…

PowerShell: Notify Each User Before Password Expires

# This script email users basing on their password expiration dates # User input variables…

SQL: Use PowerShell to Generate a Database Object From Another Object

Have you ever wondered about the prospect of automating T-SQL executions on Windows? As your…