Here's my code. I have tried using 'mail' as protocol, yet still doesn't deliver. But it does get delivered on localhost perfectly and on other servers. But on this particular vps server, it doesn't. Thanks in advance.
$config = array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => 'myemail@gmail.com',
'smtp_pass' => '***********',
'smtp_timeout' => 10,
'mailtype' => 'html',
'starttls' => true,
'newline' => "\r\n",
);
$this->load->library('email');
$this->email->initialize($config);
$this->email->from($sender);
$this->email->to($email);
$this->email->subject($subject);
$this->email->message($mailToSend);
$flag = $this->email->send();
if ($flag) {
return $flag;
} else {
return false;
}