tarickb / sasl-xoauth2

SASL plugin for XOAUTH2
Other
72 stars 20 forks source link

Can't send email [SOLVED] #12

Closed Wasca closed 3 years ago

Wasca commented 3 years ago

Hi,

Thanks for creating this project, I've almost got it all working but I'm getting stuck.

I'm installed on Ubuntu 20.04 LTS via the pre-built package but getting stuck when trying to send with postfix, here are the errors I'm seeing. Obfuscated of course.

Dec 10 16:29:52 cmtweb postfix/postfix-script[144145]: warning: symlink leaves directory: /etc/postfix/./makedefs.out Dec 10 16:29:52 cmtweb postfix/postfix-script[144156]: warning: not owned by root: /var/spool/postfix/etc/tokens Dec 10 16:29:52 cmtweb postfix/postfix-script[144157]: warning: not owned by root: /var/spool/postfix/etc/tokens/services@optuma.com Dec 10 16:30:55 cmtweb postfix/qmgr[141111]: 812892EE895: from=<root@someserver>, size=377, nrcpt=1 (queue active) Dec 10 16:30:55 cmtweb postfix/qmgr[141111]: 8A12B2EE891: from=<root@someserver>, size=377, nrcpt=1 (queue active) Dec 10 16:30:55 cmtweb postfix/qmgr[141111]: 6929B2EE3B9: from=<root@someserver>, size=377, nrcpt=1 (queue active) Dec 10 16:30:55 cmtweb postfix/qmgr[141111]: 2B5F42EE3D1: from=<root@someserver>, size=377, nrcpt=1 (queue active) Dec 10 16:30:55 cmtweb postfix/qmgr[141111]: E7A562EE3D3: from=<root@someserver>, size=377, nrcpt=1 (queue active) Dec 10 16:30:55 cmtweb postfix/qmgr[141111]: F370B2EE3C6: from=<root@someserver>, size=377, nrcpt=1 (queue active) Dec 10 16:30:55 cmtweb postfix/qmgr[141111]: 3015F2EE3CA: from=<root@someserver>, size=377, nrcpt=1 (queue active) Dec 10 16:30:55 cmtweb postfix/qmgr[141111]: 3F2562EE3C2: from=<root@someserver>, size=377, nrcpt=1 (queue active) Dec 10 16:30:55 cmtweb postfix/qmgr[141111]: 9DFB42EE885: from=<root@someserver>, size=377, nrcpt=1 (queue active) Dec 10 16:30:55 cmtweb postfix/smtp[144767]: connect to smtp.gmail.com[2404:6800:4008:c00::6d]:587: Network is unreachable Dec 10 16:30:56 cmtweb smtp: connect to smtp.gmail.com[2404:6800:4008:c00::6d]:587: Network is unreachable Dec 10 16:30:56 cmtweb postfix/smtp[144764]: 8A12B2EE891: SASL authentication failed; cannot authenticate to server smtp.gmail.com[108.177.97.108]: bad protocol / cancel Dec 10 16:30:56 cmtweb sasl-xoauth2: auth failed: 2020-12-10 16:30:56: TokenStore::Refresh: request failed Dec 10 16:30:56 cmtweb sasl-xoauth2: set log_full_trace_on_failure to see full 14 line(s) of tracing. Dec 10 16:30:56 cmtweb smtp: 8A12B2EE891: to=<testuser@gmail.com>, relay=none, delay=1107, delays=1106/0.03/1.1/0, dsn=4.4.1, status=deferred (connect to smtp.gmail.com[2404:6800:4008:c00::6d]:587: Network is unreachable) Dec 10 16:30:56 cmtweb postfix/smtp[144767]: E7A562EE3D3: to=<testuser@gmail.com>, relay=smtp.gmail.com[108.177.97.108]:587, delay=522, delays=520/0.07/1.2/0, dsn=4.7.0, status=deferred (SASL authentication failed; cannot authenticate to server smtp.gmail.com[108.177.97.108]: bad protocol / cancel) Dec 10 16:30:56 cmtweb sasl-xoauth2: auth failed: 2020-12-10 16:30:56: TokenStore::Refresh: request failed Dec 10 16:30:56 cmtweb sasl-xoauth2: set log_full_trace_on_failure to see full 14 line(s) of tracing. Dec 10 16:30:56 cmtweb smtp: connect to smtp.gmail.com[2404:6800:4008:c00::6d]:587: Network is unreachable Dec 10 16:30:56 cmtweb postfix/smtp[144766]: 2B5F42EE3D1: SASL authentication failed; cannot authenticate to server smtp.gmail.com[108.177.97.108]: bad protocol / cancel Dec 10 16:30:56 cmtweb sasl-xoauth2: auth failed: 2020-12-10 16:30:56: TokenStore::Refresh: request failed Dec 10 16:30:56 cmtweb sasl-xoauth2: set log_full_trace_on_failure to see full 14 line(s) of tracing. Dec 10 16:30:56 cmtweb smtp: 2B5F42EE3D1: to=<testuser@gmail.com>, relay=none, delay=591, delays=589/0.06/1.5/0, dsn=4.4.1, status=deferred (connect to smtp.gmail.com[2404:6800:4008:c00::6d]:587: Network is unreachable) Dec 10 16:30:56 cmtweb postfix/error[144774]: F370B2EE3C6: to=<testuser@gmail.com>, relay=none, delay=2065, delays=2063/1.6/0/0, dsn=4.4.1, status=deferred (delivery temporarily suspended: connect to smtp.gmail.com[2404:6800:4008:c00::6d]:587: Network is unreachable) Dec 10 16:30:56 cmtweb postfix/error[144774]: 3015F2EE3CA: to=<testuser@gmail.com>, relay=none, delay=2050, delays=2048/1.6/0/0, dsn=4.4.1, status=deferred (delivery temporarily suspended: connect to smtp.gmail.com[2404:6800:4008:c00::6d]:587: Network is unreachable) Dec 10 16:30:56 cmtweb postfix/error[144774]: 3F2562EE3C2: to=<testuser@gmail.com>, relay=none, delay=2089, delays=2087/1.6/0/0, dsn=4.4.1, status=deferred (delivery temporarily suspended: connect to smtp.gmail.com[2404:6800:4008:c00::6d]:587: Network is unreachable) Dec 10 16:30:56 cmtweb postfix/error[144774]: 9DFB42EE885: to=<testuser@gmail.com>, relay=none, delay=2774, delays=2773/1.6/0/0, dsn=4.4.1, status=deferred (delivery temporarily suspended: connect to smtp.gmail.com[2404:6800:4008:c00::6d]:587: Network is unreachable) Dec 10 16:30:57 cmtweb smtp: connect to smtp.gmail.com[2404:6800:4008:c00::6d]:587: Network is unreachable Dec 10 16:30:57 cmtweb postfix/smtp[144765]: 6929B2EE3B9: SASL authentication failed; cannot authenticate to server smtp.gmail.com[108.177.97.108]: bad protocol / cancel Dec 10 16:30:57 cmtweb sasl-xoauth2: auth failed: 2020-12-10 16:30:57: TokenStore::Refresh: request failed Dec 10 16:30:57 cmtweb sasl-xoauth2: set log_full_trace_on_failure to see full 14 line(s) of tracing. Dec 10 16:30:57 cmtweb smtp: 6929B2EE3B9: to=<testuser@gmail.com>, relay=none, delay=4144, delays=4142/0.04/1.7/0, dsn=4.4.1, status=deferred (connect to smtp.gmail.com[2404:6800:4008:c00::6d]:587: Network is unreachable) Dec 10 16:30:57 cmtweb smtp: connect to smtp.gmail.com[2404:6800:4008:c00::6d]:587: Network is unreachable Dec 10 16:30:57 cmtweb postfix/smtp[144763]: 812892EE895: SASL authentication failed; cannot authenticate to server smtp.gmail.com[108.177.97.108]: bad protocol / cancel Dec 10 16:30:57 cmtweb sasl-xoauth2: auth failed: 2020-12-10 16:30:57: TokenStore::Refresh: request failed Dec 10 16:30:57 cmtweb sasl-xoauth2: set log_full_trace_on_failure to see full 14 line(s) of tracing. Dec 10 16:30:57 cmtweb smtp: 812892EE895: to=<testuser@gmail.com>, relay=none, delay=1090, delays=1088/0.02/2/0, dsn=4.4.1, status=deferred (connect to smtp.gmail.com[2404:6800:4008:c00::6d]:587: Network is unreachable)

Also I've noticed every time I restart Postfix it deletes ca-certificates.crt from /var/spool/postfix/etc/ssl/certs/ca-certificates.crt

Then when I try to send another email I get this.

Dec 10 16:38:30 cmtweb postfix/pickup[148314]: 66BBB2EE897: uid=0 from=<root@someserver> Dec 10 16:38:30 cmtweb postfix/cleanup[148748]: 66BBB2EE897: message-id=<20201210063830.66BBB2EE897@server.com> Dec 10 16:38:30 cmtweb postfix/qmgr[148315]: 66BBB2EE897: from=<root@someserver>, size=377, nrcpt=1 (queue active) Dec 10 16:38:30 cmtweb postfix/smtp[148752]: connect to smtp.gmail.com[2404:6800:4008:c00::6c]:587: Network is unreachable Dec 10 16:38:32 cmtweb postfix/smtp[148752]: 66BBB2EE897: to=<testuser@gmail.com>, relay=smtp.gmail.com[108.177.97.108]:587, delay=2, delays=0.01/0.02/2/0, dsn=4.7.0, status=deferred (SASL authentication failed; cannot authenticate to server smtp.gmail.com[108.177.97.108]: bad protocol / cancel) Dec 10 16:38:32 cmtweb sasl-xoauth2: auth failed: 2020-12-10 16:38:32: TokenStore::Refresh: http error: error setting certificate verify locations:#012 CAfile: /etc/ssl/certs/ca-certificates.crt#012 CApath: /etc/ssl/certs Dec 10 16:38:32 cmtweb sasl-xoauth2: set log_full_trace_on_failure to see full 13 line(s) of tracing.

I've tested using this method outlined here and it authenticates correctly. - https://github.com/google/gmail-oauth2-tools/wiki/OAuth2DotPyRunThrough#testing-imap-and-smtp-authentication-with-oauth2

Any clues on what I can try next?

Wasca commented 3 years ago

Progress! Got it working.

When creating the OAuthID make sure to select Desktop App

image

Also if you do not have IPV6 setup and working on your server, set the following in main.cf

inet_protocols = ipv4

mine was set to

inet_protocols = all

tarickb commented 3 years ago

Thanks for the update! I've changed the terminology in the README from "Installed application" to "Desktop app" to match the changes in the Developer Console.