Account creation failed: Error connecting to mail server

Hello everyone, good afternoon.

I am trying to connect my GSuite account to the system, but it doesn’t work.
I’ve tried everything and always give the same mistake.
Account creation failed: Error connecting to mail server.

I followed this tutorial too, because I have 2FA enabled, however, but this does not work.
Any idea ?

what does your nextcloud.log say?

Good afternoon, how are you ?

this is the Log.

(I removed the restricted information)

{“reqId”:“ID”,“level”:4,“time”:“2019-12-10T19:21:25+00:00”,“remoteAddr”:“IP”,“user”:“USER”,“app”:“mail”,“method”:“POST”,“url”:"/index.php/apps/mail/api/accounts",“message”:“Creating account failed: Error connecting to mail server.”,“userAgent”:“Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36”,“version”:“”}

I’m not entirely sure but it looks like your outgoing SMTP connection doesn’t work. Do your php settings allow SMTP? Is it maybe blocked by a firewall?

Both my server and PHP allow SMTP.

I believe it is related to 2-step verification

The Nextcloud Mail app offers an extensive logging system to make it easier identifying and tracking down bugs. Please enable debug mode and set the log level to debug in your admin settings. Then, try to reproduce your issue and take another look at data/nextcloud.log, data/horde_imap.log and data/horde_smtp.log.