Codeigniter smtp from localhost

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'] = ''; //use your own isp's url

  That's it - happy codeigniting

Post your comment


No one has commented on this page yet.

RSS feed for comments on this page | RSS feed for all comments

Copywrite © 2017 Kevin Phillips All rights are reserved.

Proudly supporting opensource software