Google SMTP for the email

Description

I am unable to setup the email SMTP via Google domain. I did remove 2FA and enable pop3 and imap in the gmail settings. I also enable the settings for unauthorized app auth in the google admin console.
Everything seems to be working fine, but it doesnt send any emails at all.

Server Setup Information

Rocket.Chat Version: 3.13.2
NodeJS Version: 12.21.0 - x64
MongoDB Version: 3.6.14
MongoDB Engine: wiredTiger
Platform: linux
Process Port: 3000
Site URL: hidden :slight_smile:
=ReplicaSet OpLog: Enabled
Commit Hash: 5e9f4bc424
Commit Branch: HEAD

Any additional Information

Logs:
I20210429-15:21:42.127(-4) Updating process.env.MAIL_URL
I20210429-15:21:44.542(-4) The $MAIL_URL is ‘smtp://…:465’. You probably want ‘smtps://’ (The ‘s’ enables TLS/SSL) since ‘465’ is typically a secure port. undefined

Also these are my smtp settings:

Protocol: smtp
Host: smtp.gmail.com
Ignore TLS and pool activated
port: 465
username: the entire email with @
Password: same as gmail
From Email: Not sure, I put admin@csbtech.ca, that section was a bit confusing.

You will need secured Email for Gmail - smtps

So either port 465 or 587 with ignore TLS False

Username is you Google username, and your email is the actual email From address

So you might be joe.blogs@gmail.com

You can actually login to Google as ‘joe.blogs’ but your From address will be ‘joe.blogs@gmail.com’

Couldn’t you get around this by setting up an SMTP server inside your network that does outbound TLS to Google? I suppose you could put it in your approved senders list.

A good alternative, but running your own mail server securely, and without it getting blocked by Google, is not for the faint hearted!

@john.crisp I did exactly what you suggested and it does not work.

Protocol: smpts
Host: smtp.google.com
Username: username without @
Password: same as gmail
From email: username and @ to create full email
Ignore TLS: not active (false)

If I select port 587 then I see this in logs

Exception in defer callback: [Error: 140039672534912:error:1408F10B:SSL routines:ssl3_get_record:wrong version number:../deps/openssl/openssl/ssl/record/ssl3_record.c:332: ] {   library: 'SSL routines',   function: 'ssl3_get_record',   reason: 'wrong version number',   code: 'ESOCKET',   command: 'CONN' } 

If I select port 465 with same other settings I see this in logs

Exception in defer callback: Error: Invalid login: 535-5.7.8 Username and Password not accepted. Learn more at 535 5.7.8  https://support.google.com/mail/?p=BadCredentials q6-20020a05600c46c600b003d1f3e9df3csm10125399wmo.7 - gsmtp     at SMTPConnection._formatError (/snap/rocketchat-server/1536/programs/server/npm/node_modules/meteor/email/node_modules/nodemailer/lib/smtp-connection/index.js:784:19)     at SMTPConnection._actionAUTHComplete (/snap/rocketchat-server/1536/programs/server/npm/node_modules/meteor/email/node_modules/nodemailer/lib/smtp-connection/index.js:1536:34)     at SMTPConnection.<anonymous> (/snap/rocketchat-server/1536/programs/server/npm/node_modules/meteor/email/node_modules/nodemailer/lib/smtp-connection/index.js:540:26)     at SMTPConnection._processResponse (/snap/rocketchat-server/1536/programs/server/npm/node_modules/meteor/email/node_modules/nodemailer/lib/smtp-connection/index.js:947:20)     at SMTPConnection._onData (/snap/rocketchat-server/1536/programs/server/npm/node_modules/meteor/email/node_modules/nodemailer/lib/smtp-connection/index.js:749:14)     at TLSSocket.SMTPConnection._onSocketData (/snap/rocketchat-server/1536/programs/server/npm/node_modules/meteor/email/node_modules/nodemailer/lib/smtp-connection/index.js:189:44)     at TLSSocket.emit (events.js:400:28)     at TLSSocket.emit (domain.js:475:12)     at addChunk (internal/streams/readable.js:293:12)     at readableAddChunk (internal/streams/readable.js:267:9)     at TLSSocket.Readable.push (internal/streams/readable.js:206:10)     at TLSWrap.onStreamRead (internal/stream_base_commons.js:188:23)     at TLSWrap.callbackTrampoline (internal/async_hooks.js:130:17) {   code: 'EAUTH',   response: '535-5.7.8 Username and Password not accepted. Learn more at<br>' +     '535 5.7.8  https://support.google.com/mail/?p=BadCredentials q6-20020a05600c46c600b003d1f3e9df3csm10125399wmo.7 - gsmtp',   responseCode: 535,   command: 'AUTH PLAIN' } 

Any suggestion or hint i highly appreciated!

You may need to create an ‘app’ password if you have 2fa, this url is printed in my logs

https://support.google.com/mail/answer/7126229?visit_id=638209902576437704-2869235916&p=BadCredentials&rd=2#cantsignin&zippy=%2Ci-cant-sign-in-to-my-email-client

Unfortunately I don’t have 2fa enabled. and get the same ssl3_get_record wrong version number error for port 587

Hi there! Here to share my success in SMTP setup with google account with 2Fa enabled:
=================================================*
Protocol: smtp
Host: smtp.gmail.com
Port: 587
IgnoreTLS: off
Pool: on
Login: **********@gmail.com (your google email)
Password: **** **** **** **** (here paste password for app)
EmaiL: **********@gmail.com (same as login)
*=================================================
To obtain pass for app go to google account management - Security - 2-Step Verification - App passwords