phpmailer下载 报SSl错误

Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free.
Have encountered an issue where email should be sent from an mail server which has self signed certificate, the error which I get is :
PHP Warning:
stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages:
error::SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed in class.smtp.php on line 327.
Has anyone encountered anything similar?
I have also tried to set the stream_context params (params: ):
$options['ssl']['verify_peer'] =
$options['ssl']['verify_peer_name'] =
$options['ssl']['allow_self_signed'] =
No luck, it still fails with the same error as pointed above.
3,08861638
I have the same problem. So i changed the file class.smtp.php in line 238:
public function connect($host, $port = null, $timeout = 30, $options = array()) {
if (count($options) == 0) {
$options['ssl'] = array('verify_peer' =& false, 'verify_peer_name' =& false, 'allow_self_signed' =& true);
now it works fine!
2,45451430
PHP 5.6 introduces SSL certificate verification, so if your config is broken, it will fail with this error. You should fix your SSL, but you can revert to the old behaviour by setting the SMTPOptions property to not verify certificates:
$mail-&SMTPOptions = array(
'ssl' =& array(
'verify_peer' =& false,
'verify_peer_name' =& false,
'allow_self_signed' =& true
Editing the library defeats the entire point of libraries - and if you do as Kaf's answer suggests, your code will break when you upgrade. Really, don't do that.
4,89242544
Just wanted to put my 2 cents in since I've been looking for a fix for days until I tried Kaf's solution and it worked!! Thanks @Kaf
Anyways... For me, PHPMailer was working fine until I decided to upgrade PHP to PHP5.6
Changes were made to open ssl in PHP 5.6. Here is the official docs:
From the docs it says to set verify_peer and verify_peer_name to false
So just follow Kaf's answer and see if that works for you.
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Sign up using Stack Exchange
Post as a guest
Post as a guest
By posting your answer, you agree to the
Not the answer you're looking for?
Browse other questions tagged
Top questions and answers
Important announcements
Unanswered questions
By subscribing, you agree to the
Stack Overflow works best with JavaScript enabledphpmailer的ssl问题
[问题点数:100分,结帖人kyzy_yy_pm]
phpmailer的ssl问题
[问题点数:100分,结帖人kyzy_yy_pm]
不显示删除回复
显示所有回复
显示星级回复
显示得分回复
只显示楼主
相关帖子推荐:
2011年2月 PHP大版内专家分月排行榜第三2010年12月 PHP大版内专家分月排行榜第三
2011年2月 PHP大版内专家分月排行榜第三2010年12月 PHP大版内专家分月排行榜第三
2011年2月 PHP大版内专家分月排行榜第三2010年12月 PHP大版内专家分月排行榜第三
2008年10月 PHP大版内专家分月排行榜第二2008年9月 PHP大版内专家分月排行榜第二2008年4月 PHP大版内专家分月排行榜第二2007年12月 PHP大版内专家分月排行榜第二
2008年10月 PHP大版内专家分月排行榜第二2008年9月 PHP大版内专家分月排行榜第二2008年4月 PHP大版内专家分月排行榜第二2007年12月 PHP大版内专家分月排行榜第二
本帖子已过去太久远了,不再提供回复功能。PHPMailer是一款邮件发送插件了,我们只要简单的配置就可以实现发邮件了,但小编在配置使用ssl时发现无法连接服务器了,下面我们来看问题解决办法.
使用PHPMailer发送邮件都是使用未加密的smtp服务器,这次使用的smtp服务器要用ssl(Secure Sockets Layer,安全套接层)方式连接。好在PHPMailer支持ssl的smtp服务器,网上查了资料,以为改下端口,加上SMTPSecure设置就可以了,但是事实并非如此。代码中端口改成了465,加了$mail-&SMTPSecure = &ssl&;设置,结果PHPMailer一直提示不能连接主机。网上各种查资料,各种咨询,百般折腾后终于找到了原因,PHP没有开启扩展,汗&&windows开启扩展在php.ini文件中找到;extension=php_.dll,把前边的&分号&去掉,重启一下Apache即可。linux开启扩展cd php-5.2.14/ext//mv config0.m4 config.m4phpize./configuremakemake install&修改php.ini文件, 在适当的位置添加extension=.so给php-fpm master进程发一个USR2信号,ssl扩展添加成功。
您对本文章有什么意见或着疑问吗?请到您的关注和建议是我们前行的参考和动力&&编程开发子分类关于PHPmailer发送邮件失败之Failed to connect to server
使用phpmailer类smtp发送邮件不成功;排查思路首先在代码中,我们打开SMTPDebug$mail=newPHPMailer();//建立邮件发送类$mail-SMTPDebug=//要把SMTPDebug的属
使用phpmailer类smtp发送邮件不成功;排查思路首先在代码中,我们打开SMTPDebug$mail = new PHPMailer();
//建立邮件发送类
$mail-&SMTPDebug = & & & &//要把SMTPDebug 的属性设置为true如果邮件发送不成功,则会提示错误信息我这次报的错误是Failed to connect to serverfollowing From address failed开启DEBUG提示:ERROR: Failed to connect to server: (0)
既然是连接不上,那么我们就看是靠什么连接的,经询问度娘得知连接smtp是靠 fsockopen连接的,那么我们来看看这个函数是否被禁用在PHP.ini里查找1,allow_url_fopen = On
查看该选项是否是On,是Off时函数肯定是不能用,改成On.如果还不能用,怎么办?因为上面的配置,是说fopen是打开状态的,不是说打开了就能用,还要允许使用才能用,好,我们看看禁用的方法里有没有fsockopen2,disable_functions disable_functions 这个后面,有很多被禁用的方法,有fsockopen,好恭喜你,找到答案了,将它去掉,OK,重启 apache,搞掂还不行?同样是在php.ini文件中,看看这个打开没有?extension=php_openssl.dll如果已打开,再看看php目录下的两个扩展文件有没有拷到c/:windows/System32下libeay32.dll & ssleay32.dll另外:不改动,只改代码的情况,也可以一试,注=&我没试过方法1:将fsockopen函数替换成pfsockopen函数因为pfsockopen的参数与fsockopen基本一致,所以只需要将@fsockopen替换成@pfsockopen就可以了。如果运气好 pfsockopen没被禁用,ok通过方法2:使用stream_socket_client函数一般fsockopen()被禁,,pfsockopen也有可能被禁,所以这里介绍另一个函数stream_socket_client()。stream_socket_client的参数与fsockopen有所不同,所以代码要修改为:$this-&smtp_conn = stream_socket_client("tcp://".$host.":".$port, $errno, &$errstr, &$tval);这样就可以了。本文出自 “909是个目标” 博客,请务必保留此出处
你最喜欢的

我要回帖

更多关于 class.phpmailer.php 的文章

 

随机推荐