CodeIgniter Forums
Sending email over Office365 SMTP account with Email library - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=11)
+--- Thread: Sending email over Office365 SMTP account with Email library (/showthread.php?tid=62296)



Sending email over Office365 SMTP account with Email library - rannt - 06-29-2015

Hi!

I know this issue is probably related to server settings (Debian based), but I'll give it a try.

First of all, everything works fine on my local WAMP server but I can't send emails using my Office account on my production server. I've managed to open the port 587 in firewall configuration but still no success.

Here is the code I'm using:

PHP Code:
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'smtp.office365.com';
$config['smtp_user'] = '****';
$config['smtp_pass'] = '****';
$config['smtp_port'] = 587;
$config['smtp_timeout'] = 60;
$config['smtp_crypto'] = 'tls';
$config['mailtype'] = 'html';

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

$this->email->from('****''****');
$this->email->to('****');

$this->email->subject('Email Test');
$this->email->message('Testing the email class.');

$this->email->send(FALSE);

$this->email->print_debugger(); 

But after a while I get this error:

Code:
Message: stream_socket_enable_crypto(): SSL: crypto enabling timeout

OpenSSL is enabled (according to phpinfo()).

I tried sending an email over the same Office account with Phpmailer library and everything worked as expected!

Does anyone have a solution?


Thank you!


RE: Sending email over Office365 SMTP account with Email library - rannt - 06-29-2015

Anyone? Any help would be really appreciated. Thank you!


RE: Sending email over Office365 SMTP account with Email library - InsiteFX - 06-30-2015

Make sure you set your SMTP in your php.ini file to your office one etc;


RE: Sending email over Office365 SMTP account with Email library - rannt - 06-30-2015

I did found some settings in php.ini for smtp host and port, but it says they are for Windows only. I'm running Debian.

[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = localhost
; http://php.net/smtp-port
smtp_port = 25


RE: Sending email over Office365 SMTP account with Email library - InsiteFX - 06-30-2015

Then you will need to find out how they are setting them.


RE: Sending email over Office365 SMTP account with Email library - jasonwang.public - 10-06-2015

(06-30-2015, 09:20 PM)you\d need to use following line to override CodeIgniter's configuration parameter Wrote: ‘newline’ => “\r\n”, //must have for office365!
I published an article here:


http://aus800.com.au/sending-out-emails-using-codeigniter-from-office365-account/.