[英]mail(): Failed to connect to mailserver at “localhost” port 25, verify your “SMTP” and “smtp_port” setting in php.ini or use ini_set()
I am currently working on send mail in codeigniter below are details of smtp but I am getting error how to solve this issue some posts on stackoverflow asked to make some modifications in php.ini still getting same issue. 我目前正在在codeigniter中发送邮件,以下是smtp的详细信息,但如何处理此问题却出现了错误,关于stackoverflow的一些帖子要求在php.ini中进行一些修改,但仍然出现相同的问题。
$config = Array(//for gmail Settings
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.gmail.com',
'smtp_port' => 465,
'smtp_user' => 'xyz@gmail.com', // user details
'smtp_pass' => 'xyzxyz', // password
'mailtype' => 'html',
'charset' => 'iso-8859-1',
'wordwrap' => TRUE
);
$this->load->library('email', $config);
$this->email->set_header('MIME-Version', '1.0; charset=utf-8');
$this->email->set_header('Content-type', 'text/html');
$this->email->set_newline("\r\n");
$this->email->from('xyz@gmail.com@gmail.com', 'xyz.com'); //sender's email
$this->email->to($email); // change it to yours
$this->email->subject('Password reset email');
$message = "<h2>You have requested to reset password</h2>";
$message .= "<a href='" . base_url('controller') . "/" . "methodname/" . $reset . "'> Click here to reset your password</a>";
$this->email->message($message);
$send = $this->email->send();
This config helped me to solve my issue 这个配置帮助我解决了我的问题
$config = array(
'protocol' => 'smtp',
'smtp_host' => 'smtp.gmail.com',
'smtp_port' => 465,
'smtp_crypto' => 'ssl',
'smtp_timeout' => '30',
'smtp_user' => 'xyz@gmail.com', // your smtp user
'smtp_pass' => 'xyzxyz', // your smtp password
'wordwrap' => TRUE
);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.