doushan1863 2015-10-23 12:49
浏览 588

通过Office365使用CI3发送电子邮件时出错 - SSL操作失败,代码为1

I'm using CI3 and its Email library to send email over Office365 SMTP server. This is my code:

$config['mailtype'] = 'html';
$config['smtp_crypto'] = 'tls';
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'smtp.office365.com';
$config['smtp_user'] = '[USERNAME]';
$config['smtp_pass'] = '[PASSWORD]';
$config['smtp_port'] = '587';
$config['charset']='utf-8';
$config['newline']="
";
$config['crlf'] = "
";

$this->email->initialize($config);

$this->email->from('[FROM]', '[FROM NAME]');
$this->email->reply_to('[REPLY TO]', '[REPLY TO TEXT]');
$this->email->to($message['email']);

$this->email->subject($message['subject']);
$this->email->message($output);
$this->email->send()

Everything works fine for most of the time. But sometimes this is what I get in the error log:

ERROR - 23.10.2015 09:46:32 --> Severity: Warning --> fwrite(): SSL operation     failed with code 1. OpenSSL Error messages:
error:140D00CF:SSL routines:SSL_write:protocol is shutdown         /home/[USER]/domains/[DOMAIN]/public_html/system/libraries/Email.php 2131

The main problem is, when this starts happening, it doesn't stop until I reboot the server or the server runs out of disc space!!! And it's happening really fast, a few MB of data per second which means a file size of a few GB in a really short period of time!

I'm not sure, this is actually related to CI or maybe it's a server issue?

Thank you!

  • 写回答

1条回答 默认 最新

  • dqfkd82886 2015-10-24 03:56
    关注

    I do not think it matters but try with in this order protocol at top as I have check on StackOverflow and that is what every one else has.

    $this->load->library('email');
    
    $config['protocol'] = 'smtp';
    $config['smtp_crypto']= 'tls'; 
    $config['smtp_host'] = 'smtp.office365.com';
    $config['smtp_user'] = 'test@host.com';
    $config['smtp_pass'] = 'PASSWORD';
    $config['smtp_port'] = '587';
    $config['charset']='utf-8';
    $config['newline']="
    ";
    $config['crlf'] = "
    ";
    $config['mailtype'] = 'html';
    
    $this->email->initialize($config);
    
    $this->email->from('demo@demo.com', 'Johe Doe');
    $this->email->to(blah@demo.com);
    
    $subject = 'Some Thing';
    $this->email->subject($subject);
    
    $message = 'Hello Test';
    $this->email->message($message);
    
    $this->email->send();
    

    Codeigniter 2 user guide http://www.codeigniter.com/userguide2/libraries/email.html

    Codeigniter 3 http://www.codeigniter.com/user_guide/libraries/email.html

    Remove Lines Below.

    $this->email->reply_to('[REPLY TO]', '[REPLY TO TEXT]');
    
    评论

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料