CodeIgniter Send Email Using Gamil SMTP

In CodeIgniter send email is to easy with your Gmail account and through Gmail SMTP. Here in below SendMail function is the best example of send mail, just copy below code and pest in Controller file and set the function parameter. Here in below code, you need to add your Gmail email and account password.
public function SendMail($to,$cc,$bcc,$subject,$message){
$config[“protocol”] = “smtp”;
$config[‘mailpath’] = ‘/usr/sbin/sendmail’;
$config[“charset”] = “utf-8”;
$config[“wordwrap”] = TRUE;
$config[“crlf”] = “\r\n”;
$config[“wordwrap”] = TRUE;
$config[“smtp_timeout”] = 300;
$config[“mailtype”] = “html”;
$this->email->from(‘‘, ‘Your Name Here‘);
} else {
}return $a;


// Send mail using above function




$subject=”Your subject is here “;

$message=”Your message body is here.”



Leave a Reply

Your email address will not be published. Required fields are marked *