I have been dealing whit this problem for a wile, I tryed whit a hotmail address and it works whit no problem, but gmail it was a big problem for me.
What I did?
Well, first I go to my install path: C:\inetpub\wwwroot\moodle3.3\lib\phpmailer
And I make a copy of the file class.smtp.php.
and add two lines of code at line 255 approximately, it looks like this:
public function connect($host, $port = null, $timeout = 30, $options = array())
go to this link https://myaccount.google.com/device-activity?hl=en&pli=1
and view recent attempts to use the account and accept suspicious access.
(If you don´t use google You don´t have to do this).
I dont know if it is the best thing to do, because the phpmailer is looking for a certificate on local host and I disable the ssl check whit this, but at least now I can send emails.
credits for this guys:
I hove this can help some one else. (sorry for my bad English)
Happy New year 2018 to all of you!