Flexi Auth – Handling notifications via SMTP

Flexi Auth

Flexi Auth is an open-source user authentication / login library which is built for Codeigniter 2.0+ PHP Framework, developed by Rob Hussey from Haseydesign.

For me personally, library is a weak word, this is more like a small independent system. It has its own configuration files, models, libraries, database handling logic, therefore technically it is much more than a library.

First of all I’d like to thank Rob for this wonderful and most helpful piece of code. Its great!

Our company has used it a lot in our own system based on Codeigniter 2. The reason this article will see the light of day is because we feel the need to give back something to community which was more than generous to us in recent years.

Flexi Auth is easy to use and install. Since, this is not the point of this article, you can read further about it on their public documentation here. They have a great demo to if you want to check out the functionality.

In our projects, mostly, we have used Flexi Auth as it comes, out-of-the-box, with only simple configuration that is necessary for each project. Recently we worked on a project that requires that notifications / emails are sent via SMTP instead of internal e-mail server. This is when we have found out that this feature was not integrated to Flexi Auth.

DON’T PANIC! Solution is simple.

To achieve this we would need to change 2 files from original library.

1) application/config/flexi_auth.php


Add these lines as follows:

Setup the values as you need. Values listed in example are for Gmail SMTP.

All these settings come from Codeigniter Email Class. Since Flexi Auth is written for Codeigniter, it uses its classes, config and logic to send notification. Lucky for us! Right?

It would be useful to enable email debugging, so you can see if there are any problems during the development. this can be achieved by setting:


2) application/models/flexi_auth_model.php – line 2309


Change to:

That’s it! If you are worried about not be able to use mail server, don’t be, just change your setting and all should work fine.

At the time of writing Rob didn’t implement these changes on his GitHub repository. You can checkout these changes on our GitHub repo. Or you can download full library with changes already implemented from our forked repo.

We hope we helped, best of luck to all.
Greetings Marko/PDC

Autor: prodevcon Dev-Team

We are always hungry for code and knowledge. Our areas of expertise: Plain PHP, Codeigniter, Symphony2, Wordpress, Drupal, Typo3, Magento, etc ...

Anyone can write code that a computer can understand. Good programmers write code that humans can understand. ~Martin Fowler

Kommentar verfassen