$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'smtp.gmail.com',
'smtp_port' => 465,
'smtp_user' => 'XXXX@XXXX.com',
'smtp_pass' => 'XXXX',
'mailtype' => 'html',
'charset' => 'iso-8859-1'
);
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$this->email->from('xxxxx@xxx.com', 'xxxx');
$this->email->to($email);
$this->email->subject('Hi');
$this->email->message('Hi');
if($this->email->send())
{
echo 'Your email was sent.';
}
else
{
show_error($this->email->print_debugger());
}
But it shows the error Message: fsockopen(): unable to connect to smtp.gmail.com:465 (Connection refused).
I have seen the solution here Sending mail with CodeIgniter using SMTP protocol not working but it is not working and I am not able to find php.ini.