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!
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]');