【问题标题】:SMTP send mail by codeigniterSMTP通过codeigniter发送邮件
【发布时间】:2015-08-11 11:32:16
【问题描述】:

我尝试使用 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.

【问题讨论】:

  • 请张贴代码..

标签: codeigniter smtp


【解决方案1】:

您必须将$config['protocol'] = "smtp"; 更改为$config['protocol'] = "SMTP";

让我知道它是否适合你

【讨论】:

  • 为什么会这样?我在协议的电子邮件类中看到了 strtolower()s。
【解决方案2】:

试试下面的代码,它可以解决你的问题。它对我来说很完美。

$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();

【讨论】:

    猜你喜欢
    • 2014-03-05
    • 1970-01-01
    • 2016-04-16
    • 1970-01-01
    • 1970-01-01
    • 2023-03-19
    • 1970-01-01
    • 1970-01-01
    • 2014-12-30
    相关资源
    最近更新 更多