【发布时间】:2019-07-28 10:30:14
【问题描述】:
Error screentshot Hello guyz 我正在 codeingniter 中发送邮件功能,相同的电子邮件功能在 localhost 中工作,但在实时服务器中不起作用我无法理解这个错误,请帮助我.. 这是我的电子邮件代码:
$config = array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => 'email', // change it to yours
'smtp_pass' => 'password', // change it to yours
'mailtype' => 'html',
'charset' => 'iso-8859-1',
'wordwrap' => TRUE
);
$message = "
<html>
<head>
<title>Verification Code</title>
</head>
<body>
<h2>Thank you for Registering.</h2>
<p>Your Account:</p>
<p>Dear: ".$firstname."</p>
<p>Please click the link below to activate your account.</p>
<h4><a href='".base_url()."welcome/activate/".$id."/".$code."'>Activate My Account</a></h4>
</body>
</html>
";
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$this->email->from($config['smtp_user']);
$this->email->to($email);
$this->email->subject('Signup Verification Email');
$this->email->message($message);
//sending email
if($this->email->send()){
$this->session->set_flashdata('message','Register Successfull And your Activation link send in Email Please Verify Your Account');
}
else{
$this->session->set_flashdata('message', $this->email->print_debugger());
}
错误:
Unable to send email using PHP mail(). Your server might not be configured to send mail using this method.
【问题讨论】:
-
if($this->email->send()) 在此 if 条件之后执行哪个部分...?另外,它是否显示任何错误,如果是,那是什么?
-
我只是把我的错误截图请检查它@Shujaat sir
-
好吧,如果您阅读了错误,您会发现问题所在的不是您的代码,而是邮件服务器。 Gmail 实际上拒绝接受发送电子邮件(“验证密码失败请通过您的网络浏览器登录,然后重试”)。您可能使用了错误的 gmail 凭据(请记住,gmail 的传出服务器不允许未经身份验证的发送),或者您可能启用了 2FA 或其他什么。
-
话虽如此,您应该在端口 465 上使用 (IIRC) 端口 587 和 TLS/StartTLS 而不是 SSL...您网站上显示的相同错误消息指向 this google support resource有关如何进行的更多信息
-
请将代码和错误作为文本而不是屏幕截图发布。这将最大限度地提高我们为您提供帮助的能力。
标签: php codeigniter email model-view-controller