PHP CodeIgniter 循环发送email邮件时出错 + curl证书

        使用PHP CodeIgniter框架进行开发时发现,当循环发送38封邮件时出现以下错误,并且发送很少的几封邮件,上网查了很多资料,大多数人都使用了sleep(5)解决。但我使用sleep(5),甚至sleep(10)都无法将38封邮件全部发送成功,后来改为sleep(15)总算解决问题,但发送时间偏长,用了15分钟。最后,查询框架源代码和php手册,发现了解决办法,最终发送38封邮件仅用4分钟,并且没有提示错误。

一、开发环境:

   Apache/2.4.29 (Win64) OpenSSL/1.0.2n PHP/5.6.38


二、提示问题:

A PHP Error was encountered

Severity: Warning

Message: fwrite(): SSL operation failed with code 1. OpenSSL Error messages: error:1420C0CF:SSL routines:ssl_write_internal:protocol is shutdown

Filename: libraries/Email.php

Line Number: 2268

---------------------------------------------------

A PHP Error was encountered

Severity: Warning

Message: fwrite(): SSL operation failed with code 1. OpenSSL Error messages: error:1409E10F:SSL routines:ssl3_write_bytes:bad length

Filename: libraries/Email.php

Line Number: 2268

-----------------------------------------------------

三、问题解决:

Search 'fsockopen' from PHP Manual:

Trying to fsockopen an ssl:// connection, but it was hanging for a long time, ignoring timeout parameter, and eventually returning false, without an error message.

Turns out (at least) on Windows it validates certificates and doesn't have a valid certificate store.

This worked for me:

- download Mozilla's certificate store from https://curl.haxx.se/ca/cacert.pem
- copy it inside php installation (for example: c:\php)
- and set it up in php.ini
       
              openssl.cafile="c:\php\cacert.pem"

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值