我正在尝试通过我的Gmail帐户在codeigniter中发送电子邮件。我当前的代码如下:
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => 'myemail@gmail.com',
'smtp_pass' => 'xxxxxxxxxx',
'mailtype' => 'html',
'charset' => 'iso-8859-1'
);
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$this->email->from('myemail@gmail.com', 'Test');
$this->email->to('test@gmail.com');
$this->email->subject('CodeIgniter Rocks Socks ');
$this->email->message('Hello World');
if($this->email->send()){
echo 'Your email was sent, fool.';
}
else{
show_error($this->email->print_debugger());
}
但是它显示出如下错误:
Tamilselvan 1小时前 220 smtp.googlemail.com ESMTP p2sm168603006pfi.73-gsmtp您好:250-smtp.googlemail.com为您服务,[103.66.78.244] 250尺寸35882577 250-8BITMIME 250-AUTH登录平原XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH 250- ENHANCEDSTATUSCODES 250密码250密码250 SMTPUTF8无法验证密码。错误:535-5.7.8不接受用户名和密码。要了解更多信息,请访问535 5.7.8 support.google.com/mail/?p=BadCredentials p2sm168603006pfi.73-gsmtp无法使用PHP SMTP发送电子邮件。您的服务器可能未配置为使用此方法发送邮件。
我在做什么错?该如何解决?