Use SMTP Email Settings from Database in CakePHP 2

Yesterday, one of our client requested to store SMTP email settings in database. Usually, we can do it in the email.php file. However, it is more convenient if we store it in the database and provide a web form to easily change it.

Let say we store the email settings in table called email_settings with model EmailSetting.

One of the way is to retrieve the email settings record in every email sending method you have as per below:

 // get email settings
$EmailSetting = ClassRegistry::init('EmailSetting');
$email_settings = $EmailSetting->findById(1);
$email_setting = $email_settings['EmailSetting'];

and load the SMTP email settings as per below:

if (!empty($email_setting['smtp_host'])) {
    'host' => $email_setting['smtp_host'],
    'port' => $email_setting['smtp_port'],
    'username' => $email_setting['smtp_user'],
    'password' => $email_setting['smtp_password'],

But that way will not promote a code use. After digging CakePHP cookbook, we found out that we can retrieve the email settings in the EmailConfig class (in file /app/Config/email.php). You can just load the SMTP email settings in __construct() function. It’s very convenient and you can easily change it whenever needed.

Here’s the codes:

File:  /app/Config/email.php

class EmailConfig
  public function __construct()
      $EmailSetting = ClassRegistry::init('EmailSetting');
      $email_settings = $EmailSetting->findById(1);
      $email_setting = $email_settings['EmailSetting'];

      if (!empty($email_setting['smtp_host'])) {
         $this->default = array(
             'transport' => 'Smtp',
             'from' => $email_setting['from'],
             'host' => $email_setting['smtp_host'],
             'port' => $email_setting['smtp_port'],
             'timeout' => 30,
             'username' => $email_setting['smtp_user'],
             'password' => $email_setting['smtp_password'],
             'client' => null



jQuery Trello Board Example

We just made a Trello board like prototype using jQuery.

Features: Multiple list and multiple item. Ability to sort list and item.

Try the demo here:

And get the source codes here:



CakePHP Plugin: Summernote

We came across the need to have a CakePHP plugin for Summernote. For those you haven’t heard about it, Summernote is a WYSIWYG HTML editor which enable user to insert HTML tags in a textarea input. You can try the demo here:


To quickly use it in your CakePHP project, you can try my plugin here:

We appreciate any feedback.



5 Free Bootstrap Admin Template for Your Project

If you developed a web based system like an Inventory system, a Booking system or an Accounting system, these 5 admin templates can save you a lot time developing your own admin template.

These templates is based on Bootstrap framework. You can use it in both commercial and non-commercial project.


Admin LTE



SB Admin 2



SB Admin










5 Latest Tools to Build Your Website – Fast & Easy

As Web Developer or Web Designer, using a good tools to quickly develop website for your client is a winning strategy.

Here, I list out 5 latest tools you can use to develop your websites:

1.  Pingendo


Pricing: Free

2. Pinegrow


Pricing: From $49

3. Bootstrap Studio


Pricing: From $50

4. Jetstrap


Pricing: From $16 per month



Pricing: From $4.90 per month

You’re now equipped with 5 latest editors for quickly developing your websites.

If you’re currently using one of these editors, or if we left one off the list, let us know in the comments below.


How to Setup Your Local Web Server – Fast & Easy

There are many package available out there to setup your local web server like XAMPP, WAMP and EasyPHP. All you need in the package is Apache, PHP 5.4 or latest, MySQL database and PhpMyAdmin.

Here, we show you how to setup your local web server using XAMPP on Window.

  1. Download the latest XAMPP for Window at
  2. XAMPP websiteStart the installation process by double-clicking on the XAMPP installer. Click ‘Next’ after the splash screen.step2
  3. Here, you can select the components you want to install. Choose the default selection and click ‘Next’.


  4. Choose the folder you want to install XAMPP in. This folder will hold all your web application files, so make sure to select a drive that has plenty of space.


  5. The next screen is a promo for BitNami, an app store for server software. Deselect the ‘Learn more about BitNami for XAMPP’ checkbox, unless you actually enjoy receiving promo mails!


  6. Setup is now ready to install XAMPP. Click Next and wait for the installer to unpack and install selected components. This may take a few minutes. You may be asked to approve Firewall access to certain components (such as Apache) during the installation process.step7
  7. Installation is now complete! Select the ‘Do you want to start the Control Panel now?’ checkbox to open the XAMPP control panel.step8


Testing Your XAMPP Installation

Follow these steps to test your XAMPP installation by launching the Apache web server and creating a simple PHP file.

  1. In the XAMPP control panel, click on ‘Start’ under ‘Actions’ for the Apache and MySQL module. This instructs XAMPP to start the Apache webserver and MySQL database.step9
  2. Open your web browser and type in: http://localhost or
  3. You should see the following screen. This means you’ve successfully installed XAMPP on your computer.step10
  4. We will now test whether XAMPP has installed PHP successfully. To do this, fire up Notepad and type the following into a new document:<?php
    echo ‘Hello world’;
  5. Save this file as ‘test.php’ in c:\xampp\htdocs\ (or whichever directory you installed XAMPP in)
  6. Navigate to localhost/test.php. You should see the “Hello World” message:

Congratulations! You have now successfully installed XAMPP on your PC. You can now use your local Apache webserver to install our scripts.



How to Create a Change Log for Your Product

At, we will require to create a nice change log file which is readable to our customers each time a project released. It will become cumbersome if there are a lot of log files to create. Since all our projects used Git as source code repository, generating a change log from the Git history will help us cut down our time a lot.

Here are the git command we used to generate the change log files:

$ git log –since=”2015-09-01″ –name-only –date=short –pretty=”%nDate: %cd%nCommit ID: %h%nDescription: %s%n%nAffected files:” > Recent_Changes.txt

This command will generate a nice change log file (changelog.txt) like the above screenshot. You may adjust
“–since=” as per your commits date.




Thank you for visiting our blog. This blog will become our platform for us to share our tips, tutorials, articles etc to you. We hope that it will add value to your work, business and life.

Stay tunes for more updates. Sharing is caring.

Thank you for supporting us.

Hand holding a stone heart on the beach. Symbol of life.

Hand holding a stone heart on the beach. Symbol of life.