大家好,我正在尝试向自己发送电子邮件以进行测试。我在cpanel上托管了网站,我使用Codeigniter库发送电子邮件。
这是我控制器中的代码
$config = array();
// $config['useragent'] = "CodeIgniter";
$config['mailpath'] = "/usr/sbin/sendmail";
$config['protocol'] = "smtp";
$config['smtp_host'] = "ssl://smtp.googlemail.com";
$config['smtp_port'] = "465";
$config['smtp_user']="myemail@gmail.com";
$config['smtp_pass']="mypass";
// $config['mailtype'] = 'html';
// $config['charset'] = 'utf-8';
// $config['newline'] = "\r\n";
// $config['wordwrap'] = TRUE;
$this->load->library('email');
$this->email->initialize($config);
$this->email->from('myemail@gmail.com', 'xyz');
$this->email->to('myemail@gmail.com');
$this->email->subject('Email Test');
$this->email->message('Testing the email class.');
if($this->email->send())
{
echo 'Email send.';
}
else
{
show_error($this->email->print_debugger());
}
这是我得到的错误
20 smtp.googlemail.com ESMTP q194sm1834461pfq.43 - gsmtp
hello: 250-smtp.googlemail.com at your service, [43.225.55.90]
250-SIZE 35882577
250-8BITMIME
250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-CHUNKING
250 SMTPUTF8
Failed to authenticate password. Error: 534-5.7.14 Please log in via your
web browser and 534-5.7.14 then try again. 534-5.7.14 Learn more at 534
5.7.14 https://support.google.com/mail/answer/78754 q194sm1834461pfq.43 -
gsmtp
Unable to send email using PHP SMTP. Your server might not be configured
to send mail using this method.
请帮帮我。真的很困惑这个过程应该如何。提前致谢