Posts Tagged ‘wamp’

CodeIgniter Controller for Sending Email via Gmail SMTP

Posted in post on June 12th, 2010 by Aditya – 3 Comments
function Index()
	{
    $config = Array(
      'protocol' => 'smtp',
      'smtp_host' => 'ssl://smtp.googlemail.com',
      'smtp_port' => 465,
      'smtp_user' => 'SuperAwesomeAccount@gmail.com',
      'smtp_pass' => 'SuperAwesomePassword'

    );

    $this->load->library('email', $config);
    $this->email->set_newline("\r\n"); /* for some reason it is needed */

    $this->email->from('SuperAwesomeAccount@gmail.com', 'Aditya Lesmana Test');
    $this->email->to('SuperAwesomeReceiver@gmail.com');
    $this->email->subject('This is an email test');
    $this->email->message('it is working Darling :D ');

    if($this->email->send())
    {
      echo 'Your email was sent, dammit';
    }
    else
    {
      show_error($this->email->print_debugger());
    }

	}

notice that I load the email library everytime this class is called and not via application/config/autoload.php

$this->load->library('email', $config);

and pay attention to

    $config = Array(
      'protocol' => 'smtp',
      'smtp_host' => 'ssl://smtp.googlemail.com',
      'smtp_port' => 465,
      'smtp_user' => 'SuperAwesomeAccount@gmail.com',
      'smtp_pass' => 'SuperAwesomePassword'

    );

can be moved (not copy, MOVED) more ood-ly into config/email.php (in this case CI will try to look for config for ‘email’ controller at config folder named ‘email’. Inside config/email.php the code wil turn something like

<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

$config['protocol'] = 'smtp';
$config['smtp_host'] = 'ssl://smtp.googlemail.com';
$config['smtp_port'] = 465;
$config['smtp_user'] = 'SuperAwesome@gmail.com';
$config['smtp_pass'] = 'Alamak';

in which you need to change controller/email.php, removing unnecessary $config

$this->load->library('email', $config);

to

$this->load->library('email');

the first line is to prevent unauthorized access while the rest is pretty self explanatory.

ps: the closing statment for php is not mandatory. Omitting them is considered best practice

via

http://net.tutsplus.com/articles/news/codeigniter-from-scratch-day-3

Enabling SSL Socket for Sending Email via SMTP

Posted in post on June 12th, 2010 by Aditya – 1 Comment

I keep getting this error whenever I want to run tutorial created by Jeffery http://net.tutsplus.com/articles/news/codeigniter-from-scratch-day-3/

A PHP Error was encountered
Severity: Warning
Message: fsockopen() [function.fsockopen]: unable to connect to ssl://smtp.googlemail.com:465 (Unable to find the socket transport “ssl” – did you forget to enable it when you configured PHP?)
Filename: libraries/Email.php
Line Number: 1652

Based on cursory research, I try to fix it by enabling php_openssl from my wamp’s php.ini … and it works like charm.

WAMP Apache Not Working – Unblocking Port 80.

Posted in post on May 12th, 2010 by Aditya – 5 Comments

The problem: I run WAMP (or XAMMP) but for some reason the apache component could not run (the icon showed some yellowish bar or red bar appear on WAMP icon on the task bar.

Quick checks reveals that port 80, which happens to be used by Apache was blocked by other application.

Some steps that can be done to solve this problem, any one of these steps should work. If not, just choose other options.

  1. Shut down Skype. Yes Skype apparently block port 80 (if no other application use it). Click on the WAMP icon and select ‘Refresh all service’. Feel free to run Skype again.
  2. CTRL-ALT-DEL, go to process tabs and kill ‘Skype.exe’ process. ‘Refresh all service’ as #1 and reload skype.
  3. Slightly harder: go to command prompt, type ‘netstat -ao’ and find ‘:80′ on ‘Local Address’ column. Jot down the PID value of that line. Go to Task Manager –> process tabs –> select view –> select columns –> tick PID –> kill process with the same PID as application that clog port 80 (this is safer than information given by WAMP –> test port 80 as only the really really correct process is killed)

Any other suggestion?