电子邮件不发送代码错误
发送邮件时发生错误..无法验证密码。错误:535-5.7.8用户名和密码不被接受。了解详情,请访问535 5.7.8 https://support.google.com/mail/?p=BadCredentials d190sm18198379pgc.53 - gsmtp 无法使用PHP SMTP发送电子邮件。您的服务器可能未配置为使用此方法发送邮件。电子邮件不发送代码错误
<?php
public function sendmail()
{
if($this->input->post()){
$email=$this->input->post('email');
$config = Array(
'protocol' => 'smtp',
'mailtype' => 'html',
'smtp_host' => 'ssl://smtp.gmail.com',
'smtp_port' => '465',
'smtp_user' => '[email protected]',
'smtp_pass' => 'xxxxxxx',
'useragent' => 'CodeIgniter',
'crlf' => '\r\n',
'newline' => '\r\n'
);
$this->load->library('email', $config);
$this->load->library('email');
$password="<p>This email has been sent as a request to reset our password</p>";
$from='[email protected]';
$to=$email;
$subject='forget password';
$this->email->from($from);
$this->email->to($to);
$this->email->subject($subject);
$this->email->message($password);
if($this->email->send()){
$this->session->set_flashdata('email','We sent your password to your Email...!');
}
else{
echo $this->email->print_debugger();
}
}
else{
$this->load->view('adminlogin');
}
}
首先,由于您的错误表示您需要检查ID,密码正确。
下面是完整的代码:尝试这个
<?php
public function sendmail()
{
if($this->input->post()){
$email=$this->input->post('email');
$config = Array(
protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com', //Your Host
'smtp_port' => '25',
'smtp_user' => '[email protected]', // change it to yours, server email
'smtp_pass' => 'xxx',
'mailtype' => 'html',
'charset' => 'iso-8859-1',
'wordwrap' => TRUE
);
$this->load->library('email', $config);
$password="<p>This email has been sent as a request to reset our password</p>";
$from='[email protected]';
$to=$email;
$subject='forget password';
$this->email->from($from);
$this->email->to($to);
$this->email->subject($subject);
$this->email->message($password);
if($this->email->send()){
$this->session->set_flashdata('email','We sent your password to your Email...!');
}
else{
echo $this->email->print_debugger();
}
} else {
$this->load->view('adminlogin');
}
}
用户名和密码是否正确..有没有在Gmail中做的其他设置.. – Anu
是@Anu你可以在[这里]找到它(https://www.formget.com/send-email-via-gmail-smtp-server-in-php/) –
您好我认为这将解决您的问题。
如果你使用gmail发送你的问题,请花点时间试试这个解决方案。
- 变化
'smtp_host' => 'ssl://smtp.gmail.com'
到'smtp_host' => 'smtp.gmail.com'
- 添加
'smtp_crypto' => 'tls'
- 变化
'smtp_port' => '465'
到'smtp_port' => '587'
- 在电子邮件帐户中创建一个应用程序的密码,并在您的应用程序凭据用它换取您的真实密码。
- 在您的电子邮件帐户中启用安全性较低的应用。
这些是我以前遇到问题时所做的解决方案。希望能帮助到你。
您的错误消息表明智能的东西,如*“用户名和密码不被接受”*,特别是*“了解更多http:// thissuperinformativepage”*。您是否尝试过阅读该错误并关注该链接? – GolezTrol
顺便说一句:在网上分享您的凭据很好。这显然是你永远不应该做的事!我会尽快更改它们! - **我的意思是**的实际密码,因为即使您进行了编辑,问题的历史记录仍会保留在那里。 – GolezTrol
''crlf'=>'\ r \ n',//应该是“\ r \ n”' - 这意味着,您应该学习一些基础知识。 http://php.net/manual/en/language.types.string.php#language.types.string.syntax.double – CBroe