How to access and run PHP with command Line in Windows

You need to add your PHP installation directory to the %PATH% environment variable, or work from the PHP installation directory.

To add it to path (The best approach – Edited for Windows 7):

  • Right-click on a My Computer icon
  • Click Properties
  • Click Advanced system settings from the left nav
  • Click Advanced tab
  • Click Environment Variables button
  • In the System Variables section, select Path (case-insensitive) and click Edit button
  • Add a semi-colon (;) to the end of the string, then add the full file system path of your PHP installation (e.g. C:\Program Files\PHP)
  • Keep clicking OK etc until all dialog boxes have disappeared
  • Close your command prompt and open it again
  • Sorted

Alternatively, you can run cd <PHP installation path> before you try and run you command, or call your script like <FULL file system path of php.exe> <path to script>

Reference:

  1. How to access PHP with the command Line in Windows
  2. Run php file in windows cmd

SMTP gmail on Codeigniter 3

I got this article from stackoverflow as always 😀

Use the following code

And dont froget to unable following two security settings in google.

1) https://www.google.com/settings/security/lesssecureapps << turn it on

2) https://accounts.google.com/b/0/DisplayUnlockCaptcha << Click continue

** Turn off 2 step verification if you have it enabled.

Code :

$config = Array(
        'protocol' => 'smtp',
        'smtp_host' => 'ssl://smtp.gmail.com',
        'smtp_port' => 465,
        'smtp_user' => 'dkumara85@gmail.com',    //email id
        'smtp_pass' => 'xxxxxxxxxxx',            // password
        'mailtype'  => 'html', 
        'charset'   => 'iso-8859-1'
    );
    $this->load->library('email', $config);
    $this->email->set_newline("\r\n");

    $this->email->from('dkumara85@gmail.com','my name');
    $this->email->to("dkumara85@gmail.com"); // email array
    $this->email->subject('email subject');   
    $this->email->message("my mail body");

    $result = $this->email->send();


    show_error($this->email->print_debugger());  // for debugging purpose :: remove this once it works...