我尝试使用codeigniter使用SMTP发送邮件。但是得到以下问题。 即使我的凭证是正确的,我在gmail中打开时工作正常。之后我得到了以下信息。
220 smtp.gmail.com ESMTP uo6sm2505144wjc.1 - gsmtp
hello: 250-smtp.gmail.com at your service, [198.58.84.54]
250-SIZE 35882577
250-8BITMIME
250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN 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 uo6sm2505144wjc.1 - gsmtp
from: 530-5.5.1 Authentication Required. Learn more at
530 5.5.1 https://support.google.com/mail/answer/14257 uo6sm2505144wjc.1 - gsmtp
The following SMTP error was encountered: 530-5.5.1 Authentication Required. Learn more at 530 5.5.1 https://support.google.com/mail/answer/14257 uo6sm2505144wjc.1 - gsmtp
to: 530-5.5.1 Authentication Required. Learn more at
530 5.5.1 https://support.google.com/mail/answer/14257 uo6sm2505144wjc.1 - gsmtp
The following SMTP error was encountered: 530-5.5.1 Authentication Required. Learn more at 530 5.5.1 https://support.google.com/mail/answer/14257 uo6sm2505144wjc.1 - gsmtp
to: 530-5.5.1 Authentication Required. Learn more at
530 5.5.1 https://support.google.com/mail/answer/14257 uo6sm2505144wjc.1 - gsmtp
The following SMTP error was encountered: 530-5.5.1 Authentication Required. Learn more at 530 5.5.1 https://support.google.com/mail/answer/14257 uo6sm2505144wjc.1 - gsmtp
data: 530-5.5.1 Authentication Required. Learn more at
530 5.5.1 https://support.google.com/mail/answer/14257 uo6sm2505144wjc.1 - gsmtp
The following SMTP error was encountered: 530-5.5.1 Authentication Required. Learn more at 530 5.5.1 https://support.google.com/mail/answer/14257 uo6sm2505144wjc.1 - gsmtp
502 5.5.1 Unrecognized command. uo6sm2505144wjc.1 - gsmtp
The following SMTP error was encountered: 502 5.5.1 Unrecognized command. uo6sm2505144wjc.1 - gsmtp
Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.
User-Agent: CodeIgniter
Date: Tue, 11 Aug 2015 11:07:54 +0000
From: "Admin" <sflowask@gmail.com>
Return-Path: <sflowask@gmail.com>
To: pankaj.kumar.k@kindlebit.com
Subject: =?utf-8?Q?Welcome_for_new_signup?=
Reply-To: "sflowask@gmail.com" <sflowask@gmail.com>
X-Sender: sflowask@gmail.com
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <55c9d78b01533@gmail.com>
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary="B_ALT_55c9d78b01d05"
This is a multi-part message in MIME format.
Your email application may not support this format.
答案 0 :(得分:4)
您必须将$config['protocol'] = "smtp";
更改为$config['protocol'] = "SMTP";
让我知道它是否适合你
答案 1 :(得分:0)
尝试以下代码,可能会解决您的问题。它对我来说非常适合。
$config = array();
$config['useragent'] = "CodeIgniter";
$config['mailpath'] = "/usr/bin/sendmail"; // or "/usr/sbin/sendmail"
$config['protocol'] = "smtp";
$config['smtp_host'] = "localhost";
$config['smtp_port'] = "25";
$config['mailtype'] = 'html';
$config['charset'] = 'utf-8';
$config['newline'] = "\r\n";
$config['wordwrap'] = TRUE;
$this->load->library('email');
$this->email->initialize($config);
$this->email->message = "Your Message";
$this->email->subject("Message Subject");
$this->email->from("user@gmail.com");
$this->email->to("admin@gmail.com");
$this->email->send();