I have configures sendmail to send email via my GMail (Google Mail) account, i.e. via smtp.gmail.com
, by editing /etc/mail/sendmail.mc
and regenerating sendmail.cf:
-dnl define(`SMART_HOST',`smtp.your.provider')
+define(`SMART_HOST',`[smtp.gmail.com]')
-dnl define(`confAUTH_OPTIONS', `A p')dnl
+define(`confAUTH_OPTIONS', `A p')dnl
-dnl TRUST_AUTH_MECH(`EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
-dnl define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')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(`no_default_msa',`dnl')dnl
FEATURE(`smrsh',`/usr/sbin/smrsh')dnl
+FEATURE(`authinfo',`hash -o /etc/mail/authinfo.db')dnl
FEATURE(`mailertable',`hash -o /etc/mail/mailertable.db')dnl
FEATURE(`virtusertable',`hash -o /etc/mail/virtusertable.db')dnl
-dnl MASQUERADE_AS(`mydomain.com')dnl
+MASQUERADE_AS(`gmail.com')dnl
Above is shortened diff of my changes to sendmail.mc.
I have created /etc/mail/authinfo
with my credentials (username and password for my GMail account; redacted):
AuthInfo:smtp.gmail.com "U:user@gmail.com" "P:password" "M:PLAIN"
AuthInfo: "U:user@gmail.com" "P:password" "M:PLAIN"
But this setup makes 'sendmail' send emails via standard SMTP port 25 using smtp.gmail.com... but lately my ISP added firewall rule which blocks all traffic to (insecure) port 25.
How to configure sendmail to send emails via port 465 or 587 (using STARTTLS)?