在发送简报类邮件时,我遇到了这个奇怪的问题.
在for循环中,我遍历数据库中的所有用户并尝试向他们发送包含一些基本信息的所有HTML邮件.现在问题是前200个左右的邮件运行良好,但随后脚本崩溃并发出以下错误:
Warning: fwrite(): SSL operation Failed with code 1. OpenSSL Error messages: error:140D00CF:SSL routines:SSL_write:protocol is shutdown in /opt/zendframework2/library/Zend/Mail/Protocol/AbstractProtocol.PHP on line 263 Warning: fwrite(): SSL operation Failed with code 1. OpenSSL Error messages: error:140D00CF:SSL routines:SSL_write:protocol is shutdown in /opt/zendframework2/library/Zend/Mail/Protocol/AbstractProtocol.PHP on line 263 Fatal error: Uncaught exception 'ZendMailProtocolExceptionRuntimeException' with message 'Could not read from smtp.gmail.com' in /opt/zendframework2/library/Zend/Mail/Protocol/AbstractProtocol.PHP:308 Stack trace: #0 /opt/zendframework2/library/Zend/Mail/Protocol/AbstractProtocol.PHP(339): ZendMailProtocolAbstractProtocol->_receive(300) #1 /opt/zendframework2/library/Zend/Mail/Protocol/Smtp.PHP(358): ZendMailProtocolAbstractProtocol->_expect(221, 300) #2 /opt/zendframework2/library/Zend/Mail/Protocol/Smtp.PHP(394): ZendMailProtocolSmtp->quit() #3 /opt/zendframework2/library/Zend/Mail/Protocol/AbstractProtocol.PHP(115): ZendMailProtocolSmtp->_disconnect() #4 [internal function]: ZendMailProtocolAbstractProtocol->__destruct() #5 {main} thrown in /opt/zendframework2/library/Zend/Mail/Protocol/AbstractProtocol.PHP on line 308
现在,我不熟悉smtp,ssl&但我相信错误最重要的一行是:“无法从smtp.gmail.com中读取”.这对我没有任何意义.
我们一直发送电子邮件(丢失密码,注册邮件等),这总是(据我所知)工作正常.该脚本在短时间内发送过多邮件后崩溃.
好的,那就是问题,现在让我解释一下设置:)
我在标准的LAMP服务器(PHP 5.3.10)上运行Zend 2.2.6并使用Zend提供的标准SMTP邮件脚本.我们将Google商家应用用作邮件客户端.以下是邮件脚本的前几行:
<?PHP
namespace MailMails;
use ZendMail;
use ZendMailMessage;
use ZendMimeMessage as MimeMessage;
use ZendMimePart as MimePart;
use ZendMailTransportSmtp as SmtpTransport;
use ZendMailTransportSmtpOptions;
use MailConfigConfig;
class Base
{
private $transport, $text, $html, $to, $subject;
public function __construct()
{
$config = new Config();
$transport = new SmtpTransport();
$options = new SmtpOptions(array(
'name' => 'mydomain.com',
'host' => 'smtp.gmail.com',
'port' => 587,
'connection_class' => 'login',
'connection_config' => array(
'username' => $config->username,
'password' => $config->password,
'ssl' => 'tls'
),
));
$transport->setOptions($options);
$this->transport = $transport;
// This happens in different parts of the code.
$this->subject( $subject );
$this->to( $address );
$this->html( $html );
$this->text( $text );
$this->send();
}
?>
到目前为止我尝试过的:
>再次运行脚本
>这有不同的结果:有时它会提前中断,有时会进一步打破,但这证明脚本不会在特定地址上中断.我觉得服务器有某种冷却方式:第一次运行就像200个地址一样,但是当我直接重新运行脚本后,它会在20个地址之后中断.当我在一小时后尝试它时,脚本会在大约200个地址后再次中断.
>我试图将ssl选项更改为’ssl’并将端口选项更改为’465′,但这具有完全相同的结果.
有人熟悉这个问题吗?我不确定在哪里寻找问题,也许有人可以帮我推动正确的方向?
提前致谢! 解决方法: 较旧的网站,但可能是你的问题
http://www.serversmtp.com/en/limits-of-gmail-smtp-server
That’s because Google places all sorts of limits on the use of its SMTP service by marketers. Those limits begin with a restriction on the number of recipients who can receive the same message. If Gmail’s SMTP server detects that your message is going to more than 500 people, it disables your account.
(编辑:北几岛)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|