Who is dollar dad?

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'] = 'smtp.vodafone.co.nz'; //use your own isp's url

 

That’s it – happy codeigniting

    Leave a Reply

    * Copy this password:

    * Type or paste password here:

    617 Spam Comments Blocked so far by Spam Free Wordpress

Disclaimer

The content on this website reflects my personal view.
Most of the tutorials and tips are for my own reference which you are free to use "as is".

Recent Comments

Off Topic

Kevin Phillips is a senior web developer that works with WordPress, Codeigniter and Drupal.

He is available for remote projects.