Hello There!
I am having this issue with SMTP setup regardless if I use office360 smtp or google.
Your site couldn't communicate with your mail server. Please check your outgoing mail configuration.
Also I enabled oAuth2 after configuration but not appearing on the site.
Moodle 311 brand new install
Thanks.
Faisal
This might help... https://moodle.org/plugins/local_mailtest