简体   繁体   English

PHP无法使用TLS连接到SMTP

[英]PHP cannot connect to SMTP using TLS

In PHP, I am getting this error while sending email: 在PHP中,发送电子邮件时出现此错误:

"fsockopen() [function.fsockopen]: unable to connect to tls://smtp.gmail.com:465 (Connection timed out)". “ fsockopen()[function.fsockopen]:无法连接到tls://smtp.gmail.com:465(连接超时)”。

Can anyone help me to dynamically load openssl.ddl extention through .htaccess file or any other means other than dl(). 谁能帮助我通过.htaccess文件或dl()以外的任何其他方式动态加载openssl.ddl范围。

I am working with Yii and this is how my main.php is: 我正在使用Yii,这就是我的main.php的方式:

'mail' => array(
            'class' => 'application.extensions.yii-mail.YiiMail',
            'transportType'=>'smtp', /// case sensitive!
            'transportOptions'=>array(
                //'host'=>$smtp_host,
                'host'=>'smtp.gmail.com',
                //'username'=>$smtp_username,
            'username'=>'mailtest.test10@gmail.com',
                //'password'=>$smtp_password,
                'password'=>'testtest10',
            //'port'=>'543',
            'port'=>'465',
            'encryption'=>'tls',
            //'encryption'=>'ssl',
                ),
            'viewPath' => 'application.views.mail',
            'logging' => true,
            'dryRun' => false
        ),  

can anyone please let me know where I am wrong.... 谁能让我知道我错了...

I solved my problem. 我解决了我的问题。 Actually this configuration was working in localhost but was giving error in server. 实际上,此配置在localhost中有效,但在服务器中给出了错误。 Had to change settings to work in server. 必须更改设置才能在服务器中工作。 Changed host value to localhost and changed the username and password to same as in server settings. 将主机值更改为localhost,并将用户名和密码更改为与服务器设置中的相同。 It is working now. 现在正在工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM