Error while sending an email with CodeIgniter

前端 未结 7 1557
灰色年华
灰色年华 2020-12-06 18:25

While sending an email, I\'m receiving a bunch of such errors:

A PHP Error was encountered

Severity: Notice

Message: fwrite(): send of 12 bytes failed with         


        
相关标签:
7条回答
  • 2020-12-06 18:52

    If you are using cpanel for your website smtp restrictions are problem and cause this error.

    SMTP Restrictions

    This feature prevents users from bypassing the mail server to send mail, a common practice used by spammers. It will allow only the MTA, mailman, and root to connect to remote SMTP servers.

    This control is also adjustable in Tweak Settings.

    This setting has been updated.

    The SMTP restriction is disabled.

    I had a similar problem and had to disable SMTP Restrictions. After that all was ok.

    0 讨论(0)
  • 2020-12-06 18:52

    This is the answer that worked for me

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

    Be sure to use "\r\n" and not '\r\n'

    Also you can set this in a config file:

    $config['newline'] = "\r\n";
    $config['crlf'] = "\r\n";
    
    0 讨论(0)
  • 2020-12-06 18:53

    I try this and it's work for me

    $config['protocol'] = 'smtp';
    $config['smtp_crypto'] = 'tls';
    $config['smtp_host'] = 'smtp.gmail.com';    
    $config['smtp_port'] = '587';
    
    0 讨论(0)
  • 2020-12-06 19:00

    Same problem here... but what worked for me was these set of configuration:

    $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";
    

    And the message stopped. :D

    0 讨论(0)
  • 2020-12-06 19:08

    I too was in the same situation. Was getting:

    Message: fwrite(): SSL: Broken pipe</p><p>Filename: libraries/Email.php</p><p>Line Number: 2250&

    the change that really made a difference was the 'smtp_crypto' config option set to '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';
    

    I found this solution at https://www.codeigniter.com/user_guide/libraries/email.html by searching for SSL option.

    0 讨论(0)
  • 2020-12-06 19:08

    As far as CI is concerned, there are so many issues with your email config array that could cause this error.

    If you are on local development enviroment, Try changing capitalization for "smtp" to "SMTP" with capital letters.

    If you are on a live server, try changing them to small caps.

    All in all playing with $config['protocol'] = 'smtp' capitalization some times helps.

    0 讨论(0)
提交回复
热议问题