This is my mail send code.
<?php $ci->load->library('email'); $config['protocol'] = "smtp"; $config['smtp_host'] = "ssl://smtp.gmail.com"; $config['smtp_port'] = "465"; $config['smtp_user'] = 'xxxxxxxxxxxx@gmail.com'; $config['smtp_pass'] = 'xxxxxxxxxxx'; $config['charset'] = "utf-8"; $config['mailtype'] = "html"; $config['newline'] = "rn"; $ci->email->initialize($config); $ci->email->from('xxxxxxx@xxxxx.com', 'xxxxxxx.com'); $list = array($r["email"]); $ci->email->to($list); $ci->email->subject('Recover your password.'); $ci->email->message($subject,$headers); if($ci->email->send()) { $sent=true; }else{ $sent=false; } ?>
It was working fine on the Linux server, but on the windows server same code not working.
It shows me an error:
fsockopen(): unable to connect to ssl://smtp.gmail.com:465 (Network is unreachable)
I am confused about what happened. How could I solve this problem?
I am facing the same problem with Email on a server and getting the same error. The solution for this problem is to change the
Form
$config['protocol'] = "smtp"; $config['smtp_host'] = "ssl://smtp.gmail.com";
To
$config['protocol'] = "ssmtp"; $config['smtp_host'] = "ssl://ssmtp.gmail.com";
These changes are working fine for me. Hope it will be helpful for you.
Question and answer is powered by AnsPress.io