PEAR Mail unable to connect to Gmail SMTP, failed to connect to socket

后端 未结 8 1691
广开言路
广开言路 2020-12-11 00:51

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

8条回答
  •  醉话见心
    2020-12-11 01:43

    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'
    ));
    

提交回复
热议问题