【问题标题】:Error while sending an email with CodeIgniter使用 CodeIgniter 发送电子邮件时出错
【发布时间】:2012-11-21 13:46:38
【问题描述】:

在发送电子邮件时,我收到一堆这样的错误:

A PHP Error was encountered

Severity: Notice

Message: fwrite(): send of 12 bytes failed with errno=32 Broken pipe

Filename: libraries/Email.php

Line Number: 1846

A PHP Error was encountered

Severity: Notice

Message: fwrite(): send of 39 bytes failed with errno=32 Broken pipe

Filename: libraries/Email.php

Line Number: 1846

A PHP Error was encountered

Severity: Notice

Message: fwrite(): send of 31 bytes failed with errno=32 Broken pipe

Filename: libraries/Email.php

Line Number: 1846

我已按照 CodeIgniter 用户指南配置 SMTP:

$config['protocol']='smtp';  
$config['smtp_host']='ssl0.ovh.net';  
$config['smtp_port']='465';  
$config['smtp_timeout']='10';  
$config['smtp_user']='postmaster%example.com';  
$config['smtp_pass']='password';
$config['mailtype'] = 'html';
$config['charset'] = 'utf-8';
$config['newline'] = "\r\n";
$config['useragent'] = 'Project';

配置文件似乎很好,并且正确(我检查了 OVH 的电子邮件配置文件)。

有什么解决办法吗?

【问题讨论】:

  • 尝试将协议从smtp更改为mail。我还没有检查,但谷歌告诉,它可能工作。
  • @EdwardRuchevits 它有效,但您确定它使用的是 OVH 邮件服务,而不是发送邮件或安装的后缀或类似的东西吗?我已经测试过了,即使我输入了错误的密码,它仍然会发送消息,所以它不起作用。
  • 它使用标准发送邮件。至于你的问题,这个看起来很相似:stackoverflow.com/questions/1555145/…
  • 是因为你的端口!单独使用 465 进行 SSL 连接!其余使用 25 作为端口!
  • 我在这里回答了同样的问题:stackoverflow.com/questions/4338950/…

标签: codeigniter email smtp freebsd


【解决方案1】:

我也遇到了同样的情况。得到:

消息:fwrite():SSL:管道损坏

文件名:libraries/Email.php

行号: 2250&

真正产生影响的变化是“smtp_crypto”配置选项设置为“ssl”

$config['protocol'] = 'smtp';
$config['smtp_host'] = 'ssl://example.com';
$config['smtp_crypto'] = 'ssl';
$config['smtp_port'] = '465';
$config['smtp_user'] = 'user@example.com';
$config['smtp_pass'] = 'password';
$config['mailtype'] = 'html';
$config['charset'] = 'iso-8859-1';
$config['wordwrap'] = 'TRUE';

我通过搜索 SSL 选项在 https://www.codeigniter.com/user_guide/libraries/email.html 找到了这个解决方案。

【讨论】:

    【解决方案2】:

    这是对我有用的答案

    http://biostall.com/resolving-error-with-sending-emails-via-smtp-using-codeigniter/

    请务必使用“\r\n”而不是“\r\n”

    你也可以在配置文件中设置:

    $config['newline'] = "\r\n";
    $config['crlf'] = "\r\n";
    

    【讨论】:

    • 对我的答案投了反对票的人,我可以知道为什么吗?
    • 只是为了了解我错过了什么,thks :)
    【解决方案3】:

    如果您为您的网站使用 cpanel,则 smtp 限制存在问题并导致此错误。

    SMTP 限制

    此功能可防止用户绕过邮件服务器发送 邮件,垃圾邮件发送者常用的做法。它将只允许 MTA, mailman 和 root 连接到远程 SMTP 服务器。

    此控件也可在 Tweak Settings 中进行调整。

    此设置已更新。

    SMTP 限制已禁用。

    我遇到了类似的问题,不得不禁用 SMTP 限制。 之后一切正常。

    【讨论】:

    • 我没有在我的 cpanel 中看到调整设置,你能帮帮我吗?
    【解决方案4】:

    就 CI 而言,您的电子邮件配置数组存在很多可能导致此错误的问题。

    如果您在本地开发环境中,请尝试将“smtp”的大写更改为带有大写字母的“SMTP”。

    如果您在实时服务器上,请尝试将它们更改为小型大写字母。

    总而言之,使用$config['protocol'] = 'smtp' 大写有时会有所帮助。

    【讨论】:

    • 简单回答,大写是主要错误。将 SMTP 更改为大写字母将解决问题,对其进行测试,它就像一个魅力!投票。
    【解决方案5】:

    同样的问题......但对我有用的是这些配置集:

    $config['protocol']     = 'smtp';
    $config['smtp_host']    = XXX;
    $config['smtp_user']    = XXX;
    $config['smtp_port']    = 25; // was 465
    $config['smtp_pass']    = XXX;
    $config['newline']      = "\r\n";
    

    然后消息停止了。 :D

    【讨论】:

      【解决方案6】:

      使用 smpt_port:25,它对我有用

      【讨论】:

        【解决方案7】:

        我试试这个,它对我有用

        $config['protocol'] = 'smtp';
        $config['smtp_crypto'] = 'tls';
        $config['smtp_host'] = 'smtp.gmail.com';    
        $config['smtp_port'] = '587';
        

        【讨论】:

        • 欢迎来到 SO Masjoel!此处不鼓励仅使用代码的答案,因为它们无法深入了解问题是如何解决的。请更新您的解决方案,说明您的代码如何解决手头的问题:)
        • 感谢您的建议,在我看来,对上述问题的观察较少,对不起朋友:(
        猜你喜欢
        • 2015-12-28
        • 1970-01-01
        • 2012-12-26
        • 2012-12-12
        • 1970-01-01
        • 2018-06-18
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多