Send mail with Oauth2 and SMTP Gmail failing

Moderator: crythias

Post Reply
nexus
Znuny newbie
Posts: 1
Joined: 24 Feb 2023, 14:40
Znuny Version: 6.4.5
Real Name: Luis Garcia

Send mail with Oauth2 and SMTP Gmail failing

Post by nexus »

I'm starting using Znuny 6.4.5, I've configured correctly an Oauth2 token and I've been able to fetch mail (IMAP) from a gmail account.

The problem is when I try to reply a ticket, the communication log shows the following error:
1: Trying to connect to 'smtp.gmail.com:587' on znuny.xxxx.com with SMTP type 'SMTPTLS'.

Using SMTP authentication with user 'znuny@xxxx.com' and OAuth2 token config 'znuny@xxxx.com'.

SMTP authentication failed (SMTP code: 535, ErrorMessage: 535, 5.7.8 Username and Password not accepted. Learn more at 5.7.8 https://support.google.com/mail/?p=BadCredentials m4-20020a05600c4f4400b003e209b45f6bsm2886246wmq.29 - gsmtp ).

I've configured the sendmail setting to use the Oauth token as follows:
SendMailModule: Kernel::System::Email: SMTPTLS
SendmailModule::AuthUser: znuny@xxxx.com
SendmailModule::AuthenticationType: OAuth2 Token
SendmailModule::Oauth2TokenConfigName: znuny@xxxx.com
SendmailModule::Host: smtp.gmail.com
SendmailModule::Port: 587
And having the Oauth2 Token configured as follow:
Name: znuny@xxxx.com
Client ID: xxxxx
Client secret: xxxxxx
Template: Google Mail

I've also tested changing the SendMailModule to use SMTP or SMTPS (port 465) but with the same failed results.

It seems that it is ignoring the SendmailModule::AuthenticationType option when communicating with the gmail's smtp server.

Any idea?

Thanks.
apathy
Znuny newbie
Posts: 6
Joined: 16 Feb 2023, 15:56
Znuny Version: 6.4.4
Real Name: Aleksej

Re: Send mail with Oauth2 and SMTP Gmail failing

Post by apathy »

We're using https://opar.perl-services.de/dist/MultiSMTP module with Znuny 6.4.5 and multiple Gmail accounts, had zero issues with it.

The module implements OAuth2 token authorization correctly.
root
Administrator
Posts: 3934
Joined: 18 Dec 2007, 12:23
Znuny Version: Znuny and Znuny LTS
Real Name: Roy Kaldung
Company: Znuny
Contact:

Re: Send mail with Oauth2 and SMTP Gmail failing

Post by root »

apathy wrote: 22 Mar 2023, 16:13 We're using https://opar.perl-services.de/dist/MultiSMTP module with Znuny 6.4.5 and multiple Gmail accounts, had zero issues with it.

The module implements OAuth2 token authorization correctly.
The MultiSMTP modules uses the existing OAuth 2 token, there is no new implementation. If it fails without MultiSMTP, then it fails also with it.

- Roy
Znuny and Znuny LTS running on CentOS / RHEL / Debian / SLES / MySQL / PostgreSQL / Oracle / OpenLDAP / Active Directory / SSO

Use a test system - always.

Do you need professional services? Check out https://www.znuny.com/

Do you want to contribute or want to know where it goes ?
root
Administrator
Posts: 3934
Joined: 18 Dec 2007, 12:23
Znuny Version: Znuny and Znuny LTS
Real Name: Roy Kaldung
Company: Znuny
Contact:

Re: Send mail with Oauth2 and SMTP Gmail failing

Post by root »

@nexus

Please check the envelope addresses and ensure the user obtaining the token has permission to send for the configured email address.
Have you checked all the points from the Gmail support page?

- Roy
Znuny and Znuny LTS running on CentOS / RHEL / Debian / SLES / MySQL / PostgreSQL / Oracle / OpenLDAP / Active Directory / SSO

Use a test system - always.

Do you need professional services? Check out https://www.znuny.com/

Do you want to contribute or want to know where it goes ?
Post Reply