I know this question has been asked before. I have worked through the answers, but I'm still getting a 'Failed to authenticate password. Error: 535-5.7.8' error message. My code:
$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();
This returns the following error message:
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
I have checked the username and password for my google account and know that they are correct.