fsockopen():无法连接到smtp.gmail.com:465 codeigniter live server
此代码在live server中时给我一个错误。它在本地主机中运行,但不在live server中运行。它给出错误fsockopen():无法连接到smtp.gmail.com:465 codeigniter live server,codeigniter,Codeigniter,此代码在live server中时给我一个错误。它在本地主机中运行,但不在live server中运行。它给出错误fsockopen():无法连接 public function forgetPassword() { if(isset($_POST['email']) && !empty($_POST['email'])) { $result = $this->Db_Function->loadDataForUpdate('wc_usr
fsockopen():无法连接
public function forgetPassword()
{
if(isset($_POST['email']) && !empty($_POST['email']))
{
$result = $this->Db_Function->loadDataForUpdate('wc_usr','wc_email',$_POST['email'],'nor');
if($result)
{
$config = array(
'protocol' => 'smtp',
'smtp_host' => 'smtp.gmail.com',
'smtp_user' => 'nileshivarni@gmail.com',
'smtp_pass' => 'Nilesh@1234',
'smtp_port' => 465,
'mailtype' => 'html',
'charset' => 'utf-8',
'newline' => "\r\n"
);
$this->email->initialize($config);
$this->email->from('nileshivarni@gmail.com','Varni IT Solution');
$this->email->to($_POST['email']);
$this->email->subject('Password Recovery');
$msg = '<html><head></head><body>';
$msg .= '<p>Dear ' . $result[0]['wc_fullname']. ',</p>';
$msg .= '<p> <strong >Here is your Email and Password</strong></p>';
$msg .='<p>Email : <strong>'.$result[0]['wc_email'].'</strong></p>';
$msg .='<p>Password : <strong>'.base64_decode($result[0]['wc_password']).'</strong></p>';
$msg .='<p>Thank you</p>';
$msg .='<p>The team at Varni IT Solution</p>';
$msg .='</body></html>' ;
$this->email->message($msg);
if($this->email->send()){
$response['error'] = '1';
$response['success'] = "Your Password is successfully send to your email address !";
echo json_encode($response);
}
}
else
{
$response['error']='2';
$response['errorMsg']='Sorry ! Your Email is not registered with us!';
echo json_encode($response);
}
}
公共函数伪造密码()
{
如果(设置($_POST['email'])和&!空($_POST['email']))
{
$result=$this->Db_函数->loadDataForUpdate('wc_usr'、'wc_email'、$_POST['email']、'nor');
如果($结果)
{
$config=array(
'协议'=>'smtp',
“smtp_主机”=>“smtp.gmail.com”,
'smtp_用户'=>'nileshivarni@gmail.com',
'smtp_pass'=>'Nilesh@1234',
“smtp_端口”=>465,
“邮件类型”=>“html”,
“字符集”=>“utf-8”,
“换行符”=>“\r\n”
);
$this->email->initialize($config);
$this->email->from($this)nileshivarni@gmail.com“,“Varni IT解决方案”);
$this->email->to($_POST['email']);
$this->email->subject(“密码恢复”);
$msg='';
$msg.='亲爱的'.$result[0]['wc_fullname'].',';
$msg.='这是您的电子邮件和密码';
$msg.='电子邮件:。$result[0]['wc_Email'].';
$msg.='密码:'.base64\u解码($result[0]['wc\u Password'])。';
$msg.='谢谢你';
$msg.='Varni IT解决方案团队;
$msg.='';
$this->email->message($msg);
如果($this->email->send()){
$response['error']='1';
$response['success']=“您的密码已成功发送到您的电子邮件地址!”;
echo json_编码($response);
}
}
其他的
{
$response['error']='2';
$response['errorMsg']=“对不起!您的电子邮件未在我们注册!”;
echo json_编码($response);
}
}
首先,如果您在任何实时服务器中,则无需定义:
$config = array( 'protocol' => 'smtp',
'smtp_host' => 'smtp.gmail.com',
'smtp_user' => 'nileshivarni@gmail.com',
'smtp_pass' => 'Nilesh@1234',
'smtp_port' => 465);
发送邮件的上述值:只需定义
$config = array(
'mailtype' => 'html',
'charset' => 'utf-8',
'newline' => "\r\n");
完成了。这是在live server中的工作