[php] Codeigniter Email

I have got stucked in sending mail to my gmail using localhost,
Could anyone let me know about how to work with smtp_port, smtp_host and mailpath.
The code of my controller is:

class Mails extends CI_Controller {
    public function __construct() {
        parent:: __construct();

    public function index(){
        $config = Array (
            'protocol'  =>  'sendmail',
            'mailpath'  =>  '/usr/sbin/sendmail',
            'smtp_host' =>  'ssl://smtp.googlemail.com',
            'smtp_port' =>  25,
            'smtp_user' =>  'pratyakshgupta7@gmail.com',
            'smtp_pass' =>  '',
            'mailtype'  =>  'html',
            'charset'   =>  'iso-8859-1',
            'wordwrap'  =>  TRUE
        $this->email->subject('Email Test');
        $this->email->message('Testing the email class.');
        if($this->email->send() )
            echo"Email Sent Successfully";
        } else {
            echo "Mail not sent Successfully";


I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.

Note: Backticks are not single quotes.


1 Like