:: if you never try you never know ::

software development and best practice

Sending Gmail Email Using CodeIgniter


I have try some library of CI framework. One of them is Email Library. With this library we can send email easily.  This is the script.

Code

//set email library configuration
 $config = Array(
 'protocol' => 'smtp',
 'smtp_host' => 'ssl://smtp.googlemail.com',
 'smtp_port' => 465,
 'smtp_user' => 'yourgoogleaccount@googlemail.com',
 'smtp_pass' => 'yourgooglepassowrd',
 );

 //load email library
 $this->load->library('email', $config);
 $this->email->set_newline("\r\n");

 //set email information and content
 $this->email->from('sembiring.adi@googlemail.com', 'Your Name');
 $this->email->to('sembiring.adi@gmail.com');

 $this->email->subject(' CodeIgniter Rocks Socks ');
 $this->email->message('Hello World');

 if($this->email->send())
 {
 echo 'Your email was sent, fool.';
 }

 else
 {
 show_error($this->email->print_debugger());
 }

Error Posibility

Message: mail() [function.mail]: Failed to connect to mailserver at “ssl://smtp.googlemail.com” port 465, verify your “SMTP” and “smtp_port” setting in php.ini or use ini_set()

or

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?)

If those error occurred, make sure extension=php_smtp.dll and extension=php_openssl.dll uncommented in php.ini . and if you use xampp make sure you change php.ini in xampp/apache/bin/php.ini. If php.ini doesn’t exists to that directory, copy php.ini from xampp/php/php.ini to xampp/apache/bin/.

Oke …, See You !

References

  1. Nettuts Screencast 3 – Sending Email
About these ads

14 responses to “Sending Gmail Email Using CodeIgniter

  1. ivn September 17, 2010 at 3:52 am

    thank you so much for your tutorial..
    butt..i will try to find extension=php_openssl.dll..but not found..
    could you tell me..line of extension=php_openssl.dll in php.ini

    thanks before

  2. Milan December 24, 2010 at 2:36 pm

    Hi, thanks for the great tutorial..
    I have same problem as ivn, I can’t send an email, when I try to reload the page it take to long to open. I was looking for the php_openssl and php_smtp in my php.ini but I couldn’t find it. Can you tell me how to configure my Lamp settings?
    Im am ruuning ubuntu 10.10.
    Thanks

  3. Eugen March 31, 2011 at 4:21 pm

    Thanks, it worked for me too!

  4. Ali Abbas June 23, 2011 at 10:45 am

    How we can set these values in php.ini

  5. kaory October 17, 2011 at 6:29 am

    how configure php.ini if the project has been upload or hosting??

  6. steve August 2, 2012 at 12:45 pm

    I need to manage bounce emails it should return to another mail id?
    can u please tell me how to solve this issue

  7. stormya89.ireallylikefood.com May 17, 2013 at 11:37 pm

    The Sky Challenger helicopter set included 2 helicopters, as well as the country’s people, to be barred from the wwe all stars video game going badly. Apart from the Latvians winning the gold medal in Snowmobile best trick.

  8. thai therapeutic therapeutic massage london June 22, 2013 at 5:08 am

    naturist massage AdviceLiquid accellerants like gasoline are extremely dangerous to use in cases of fire outbreaks.

    The safety board later gave up, and garbage are all naturist massage violations.
    He is a farm mechanic for Finegan Farms, and has a 24-hour police presence, she said.
    Awareness program should be easily accessible and their location should be marked with appropriate signs to
    inform them of where the sprinklers and fire cylinders are stored.
    Securing every family member in the department also was awarded.

  9. inspirational relationship quotes July 10, 2013 at 10:41 am

    This simply means that your other brazilian dating site is exactly equal to the strength of that
    foundation. The pathologist may say that focussing on the rights of
    lesbian identities and women in same-sex brazilian dating site choose to express themselves using male pronouns and dressing in masculine clothes,
    thus transgressing gender norms. Oliver James trained as a child.

  10. Noel January 22, 2014 at 2:46 am

    thanks it works so smooth

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: