Codeigniter smtp from localhost
Submitted by kevin on Sat, 12/10/2011 - 16:46
Just a quick tip on how to use smtp on codeigniter from your localhost without using gmail etc.
First of all, with codeigniter 2+ you can create separate directories inside your application/config folder
ie
application/config/development/
and
application/config/production/
Codeigniter takes it's lead from the main index.php file where you can set the ENVIRONMENT constant.
So in this sub folders you can have database.php with settings for localhost (development) or your live server(production).
Did you know that you can also put your email library configuration config file in these directories ?
I find that MAMP and WAMP seem to have problems using the default php mail function so I like to use my ISP's smtp server when I'm on localhost. In most cases you don't need a password (they allow through their network protocol).
So in application/config/development/email.php add
<?php if ( ! defined('BASEPATH')) exit ('No direct script access allowed') $config['protocol'] = 'smtp'; $config['smtp_host'] = 'smtp.vodafone.co.nz'; //use your own isp's url
That's it - happy codeigniting
Add new comment