【问题标题】:Swiftmailer broken pipe errorSwiftmailer 断管错误
【发布时间】:2017-05-09 13:51:40
【问题描述】:

我正在使用:

  • RHEL 6.6
  • Symfony 2.8.18
  • PHP 5.5.30
  • Apache 2.4.10
  • MySQL 5.1.73

当我想发送 5 封或更多电子邮件时,我收到以下两条错误消息(如果我发送 1 或 2 或 4 封电子邮件,它会完美运行...):

注意:fwrite(): 发送 40 字节失败,errno=32 Broken pipe in /appli/projects/APACHE-PHP/apache_2.4/htdocs/APACHE-PHP/project/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php 在第 231 行

注意:fwrite(): 发送 6 个字节失败,errno=32 Broken pipe in /appli/projects/APACHE-PHP/apache_2.4/htdocs/APACHE-PHP/project/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php 在第 231 行

我添加了一个 Try/Catch(通过搜索其他帖子):

foreach($messages as $message){     
    try{
        $this->get('mailer')->send($message);
    }catch (Exception $e){
        printf("Error: %s\n", $e->getMessage());
        $mailer->getTransport()->stop();
        sleep(10);
    }
}

但是还是不行……

这很奇怪,因为如果我尝试使用 PHP 邮件功能的简单示例,我可以发送超过 5 封电子邮件(例如 12 封电子邮件):

<?php
$msg = "Suspendisse vestibulum et lectus eu pellentesque. ";

$headers = "From: mypersonalemail@anyidea.com" . "\r\n" .
"CC: mypersonalemail@anyidea.com";

for($i = 1; $i <= 12; $i++){
    mail("recipient@anyidea.com","Test",$msg, $headers);
}
?> 

它与 PHP mail() 函数完美配合,但是当我尝试使用 Swiftmailer 时,我可以发送超过 5 封电子邮件...为什么??

有什么建议吗?

【问题讨论】:

    标签: php email swiftmailer symfony-2.8 rhel6


    【解决方案1】:

    有很多关于此的错误报告,以及相关线程中的几种解决方法。

    (您在or close enough 上面发布的简单 try/catch 对我有用,因此我将其转发给其他正在寻找解决方案的人。)

    while (true) {
        while ($message = $queue->pop()) {
            try { $mailer->send($message); } 
            catch (Exception $e) { printf("Error: %s\n", $e->getMessage()); }
        }
        $mailer->getTransport()->stop();
        sleep(5);
    }
    

    【讨论】:

      猜你喜欢
      • 2011-03-29
      • 2017-08-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-20
      • 1970-01-01
      • 2013-04-14
      • 2016-01-11
      相关资源
      最近更新 更多