我知道之前已经问过这个问题。我已经完成了答案,但我仍然得到了“无法验证密码。错误:535-5.7.8'错误消息。 我的代码:
$config = array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => 'mygmail@gmail.com',
'smtp_pass' => '********',
'mailtype' => 'text',
'charset' => 'iso-8859-1',
);
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$this->email->from('fromgmail@gmail.com', 'My Name');
$this->email->to('mygmail@gmail.com');
$this->email->subject('Email Test');
$this->email->message('Testing Codeigniter E-mail Library.');
$this->email->send();
echo $this->email->print_debugger();
这将返回以下错误消息:
220 smtp.googlemail.com ESMTP x64sm5635644wrb.10 - gsmtp
hello: 250-smtp.googlemail.com at your service, [89.238.188.204]
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: 535-5.7.8 Username and Password not accepted. Learn more at 535 5.7.8 https://support.google.com/mail/?p=BadCredentials x64sm5635644wrb.10 - gsmtp
Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.
User-Agent: CodeIgniter
Date: Thu, 18 May 2017 08:36:24 +0000
From: "My Name" <fromgmail@gmail.com>
Return-Path: <fromgmail@gmail.com>
To: mymail@gmail.com
Subject: =?ISO-8859-1?Q?=41=73=68=20=48=69=6E=69=6E=67=20=46=61=72=6D=20=45=6E=71?= =?ISO-8859-1?Q?=75=69=72=79?=
Reply-To: "fromgmail@gmail.com" <fromgmail@gmail.com>
X-Sender: fromgmail@gmail.com
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <591d5d088406c@gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
我已经检查了我的Google帐户的用户名和密码,并知道它们是正确的。
答案 0 :(得分:0)
您需要转到帐户设置https://www.google.com/settings/security,并且需要启用Access for less secure apps
,这有助于为客户使用google smtp。
也许这会有所帮助!
答案 1 :(得分:0)