[Codeigniter] – SMTP Gmail SSL/TSL

Sending Email in Codeigniter Using Gmail’s SMTP.

<?php
$config = Array(
    'protocol' => 'smtp',
    'smtp_host' => 'ssl://smtp.googlemail.com',
    'smtp_port' => 465,
    'smtp_user' => 'gmail.login@googlemail.com',
    'smtp_pass' => 'your_password',
);
$this->load->library('email', $config);
$this->email->set_newline("\r\n");

$this->email->from('gmail.login@googlemail.com', 'Your Name');
$this->email->to('recipient@destination.tld');

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

if (!$this->email->send())
    show_error($this->email->print_debugger());
else
    echo 'Your e-mail has been sent!';
?>

5 comments

  1. Thanks for writing this.

  2. Thanks a lot. Very helpful!

  3. Your welcome Jeff, glad to help you… ^_^

  4. You write that script, or did this guy?

    http://codeigniter.com/forums/viewthread/84689/P0/

  5. I’m still learning from you, as I’m making my way to the top as well. I absolutely liked reading everything that is posted on your site.Keep the posts coming. I liked it!

Leave a Reply