Facts
I am using PEAR Mail, I want to use gmail SMTP to send a mail. I have Apache/2.4.27 (Win64) PHP/7.2.0beta3, PEAR 1.10.15, Mail 1.4.1, Net_SMT
In PHP 5.3, the tip given by others about "less secure apps," that need to be activated when logged into your Google Gmail account, solved all my problems.
In PHP 7.2 I had to do more: setting 'auth' to PLAIN and then add "verify_peer" and verify_peer_name for ssl socket_options like this:
$mail= Mail::factory('smtp', array('host' => 'ssl://smtp.gmail.com',
'port' => '465',
'auth' => 'PLAIN',
'socket_options' => array('ssl' => array('verify_peer' => false,
'verify_peer_name' => false)),
'username' => 'someAccount@gmail.com',
'password' => 'myPassword'
));