zend smtp邮件在100多封邮件后崩溃 [英] zend smtp mail crashes after 100+ mails

查看:327
本文介绍了zend smtp邮件在100多封邮件后崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在发送电子邮件时,遇到了这个奇怪的问题。

While sending a newsletter-kind-of mail I came across this weird problem.

在for循环中,我循环访问数据库中的所有用户,并尝试向他们发送一些包含一些基本信息的HTML邮件。现在的事情是,前200个左右的邮件运行正常,但是脚本崩溃并发生以下错误:

In a for loop, I loop through all the users in a database and try to send them all an HTML mail with some basic information. Now the thing is that the first 200 or so mails run fine, but then the script crashes and gives the following error:


警告:fwrite():SSL操作失败与代码1. OpenSSL错误消息:错误:140D00CF:SSL例程:SSL_write:协议在/opt/zendframework2/library/Zend/Mail/Protocol/AbstractProtocol.php关闭行263警告:fwrite():SSL操作失败,代码为1. OpenSSL错误消息:错误:140D00CF:SSL例程:SSL_write:协议在/opt/zendframework2/library/Zend/Mail/Protocol/AbstractProtocol.php中关闭263致命错误:/ opt / zendframework2 / library / Zend / Mail / Protocol / AbstractProtocol中的消息无法从smtp.gmail.com中读取的未捕获异常Zend\Mail\Protocol\Exception\RuntimeException。 php:308堆栈跟踪:#0 /opt/zendframework2/library/Zend/Mail/Protocol/AbstractProtocol.php(339):Zend\Mail\Protocol\AbstractProtocol-> _receive(300)#1 / opt / ž endframework2 / library / Zend / Mail / Protocol / Smtp.php(358):Zend\Mail\Protocol\AbstractProtocol-> _expect(221,300)#2 / opt / zendframework2 / library / Zend / Mail / Protocol /Smtp.php(394):Zend\Mail\Protocol\Smtp-> quit()#3 /opt/zendframework2/library/Zend/Mail/Protocol/AbstractProtocol.php(115):Zend\Mail \Protocol\Smtp-> _disconnect()#4 [内部函数]:Zend\Mail\Protocol\AbstractProtocol-> __ destruct()#5 {main}投入/ opt / zendframework2 / library / Zend /Mail/Protocol/AbstractProtocol.php第308行

现在,我不熟悉smtp,ssl& tls但我相信错误的最重要的一行是:无法从smtp.gmail.com读取。对我来说没有任何意义。

Now, I'm not to familiar with smtp, ssl & tls but I believe the most important line of the error is: 'Could not read from smtp.gmail.com'. Which doesn't make any sense to me.

我们一直发送电子邮件(丢失密码,注册邮件等),这总是(据我所知)工作正常。脚本在短时间内发送了太多邮件之后就崩溃了。

We send emails all the time ( lost passwords, registration mails, etc ) and this always (to my knowledge) works fine. The script just crashes after it has sent too many mails in a short period of time.

好的,那是问题,现在让我解释一下设置: )

我在标准LAMP服务器(PHP 5.3.10)上运行Zend 2.2.6,并使用Zend提供的标准SMTP邮件脚本。我们正在使用Google商业应用作为邮件客户端。以下是邮件脚本的第一行:

I'm running Zend 2.2.6 on a standard LAMP server ( PHP 5.3.10 ) and using standard SMTP mail scripts provided by Zend. We're using Google business apps as a mail client. The following is the first couple of lines of the mail script:

  <?PHP
    namespace Mail\Mails;
    use Zend\Mail;
    use Zend\Mail\Message;
    use Zend\Mime\Message as MimeMessage;
    use Zend\Mime\Part as MimePart;
    use Zend\Mail\Transport\Smtp as SmtpTransport;
    use Zend\Mail\Transport\SmtpOptions;
    use Mail\Config\Config;

    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();
        }

    ?>

到目前为止我已经尝试过:


  1. 再次运行脚本

    • 这有不同的结果:有时它会更早地破解,但是这证明脚本在特定地址上不会中断。我感觉到服务器有一些冷却:首先运行它像200个地址,但是当我直接重新运行脚本后,它可以在20个地址后断开。当我尝试一个小时后,脚本在大约200个地址之后再次断开。

有人熟悉这个问题吗?我不确定在哪里寻找问题,也许有人可以给我一个正确的方向推动?

Is anybody familiar with this problem? I'm not really sure where to look for problems, maybe someone can give me a push in the right direction?

提前感谢

推荐答案

旧网站可能是您的问题

http: //www.serversmtp.com/en/limits-of-gmail-smtp-server


这是因为Google将所有对营销人员使用其SMTP服务的限制。这些限制开始于对可以接收相同消息的收件人数量的限制。如果Gmail的SMTP服务器检测到您的消息将超过500人,则会禁用您的帐户。

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.

这篇关于zend smtp邮件在100多封邮件后崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆