0
您好我一直在嘗試使用codeigniter電子郵件庫發送電子郵件。我有以下代碼:Gmail使用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'] = '[email protected]';
$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('[email protected]', 'Harold Decapia');
$this->email->to('[email protected]');
$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" <[email protected]>
Return-Path: <[email protected]>
To: [email protected]
Subject: =?utf-8?Q?=45=6D=61=69=6C=20=54=65=73=74?=
Reply-To: "[email protected]" <[email protected]>
X-Sender: [email protected]
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <[email protected]>
Mime-Version: 1.0
>
>
> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding:
> 8bit
>
> Testing the email class.
我想強調的錯誤說:「請通過Web瀏覽器和534-登錄5.7.14然後再試一次。534-5.7.14「因爲每當我打開發送電子郵件的電子郵件地址時,我都會收到來自gmail的消息,說它阻止了一個我認爲正在運行並使用代碼的嘗試登錄登錄併發送電子郵件。我真的不知道這裏有什麼問題。有誰知道如何解決這個問題?我想要的只是能夠使用CI的庫發送電子郵件。感謝那些會回答的人。
您已啓用兩步驗證可能是 –
我試圖將其設置爲false,我仍然得到相同的輸出 –