您好我一直在尝试使用codeigniter电子邮件库发送电子邮件。我有以下代码:
$this->load->library('email');
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'ssl://smtp.gmail.com';
$config['smtp_port'] = '465';
$config['smtp_timeout'] = '7';
$config['smtp_user'] = 'myemail@gmail.com';
$config['smtp_pass'] = 'mypassword';
$config['charset'] = 'utf-8';
$config['newline'] = "\r\n";
$config['mailtype'] = 'text'; // or html
$config['validation'] = TRUE; // bool whether to validate email or not
$this->email->initialize($config);
$this->email->from('harolddecapia@gmail.com', 'Harold Decapia');
$this->email->to('harolddecapia@yahoo.com');
$this->email->subject('Email Test');
$this->email->message('Testing the email class.');
$this->email->send();
echo $this->email->print_debugger();
当我运行它时,它返回以下内容:
> 220 smtp.gmail.com ESMTP ks5sm27098152wjb.13 - gsmtp
hello: 250-smtp.gmail.com at your service, [180.191.89.193]
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 ks5sm27098152wjb.13 - gsmtp
Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.
User-Agent: CodeIgniter
Date: Wed, 16 Mar 2016 06:22:40 +0100
From: "Harold Decapia" <harolddecapia@gmail.com>
Return-Path: <harolddecapia@gmail.com>
To: harolddecapia@yahoo.com
Subject: =?utf-8?Q?=45=6D=61=69=6C=20=54=65=73=74?=
Reply-To: "harolddecapia@gmail.com" <harolddecapia@gmail.com>
X-Sender: harolddecapia@gmail.com
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <56e8eda082584@gmail.com>
Mime-Version: 1.0
>
>
> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding:
> 8bit
>
> Testing the email class.
我想强调错误说“请通过您的网络浏览器和534-5.7.14登录,然后再试一次.534-5.7.14”,因为每当我打开电子邮件地址时我都会发送电子邮件给我,Im收到来自Gmail的消息说它阻止了我尝试运行的登录尝试并使用代码登录并发送电子邮件。我真的不知道这里有什么问题。有谁知道如何解决这个问题?我想要的只是能够使用CI的库发送电子邮件。感谢那些回答的人。
答案 0 :(得分:1)
尝试转到https://accounts.google.com/DisplayUnlockCaptcha并点击继续;然后尝试再次发送电子邮件。这个答案来自here