【问题标题】:Codeigniter send mail with gmail smtp on localhostCodeigniter 在本地主机上使用 gmail smtp 发送邮件
【发布时间】:2017-02-20 08:11:09
【问题描述】:

我知道这个问题有几个重复的地方,但我想我都试过了。

我的邮件永远不会通过以下设置发送调用它:

$config = Array(
    'protocol'      => 'smtp',
    'smtp_host'     => 'smtp.gmail.com',
    //'smtp_host'     => 'localhost',
    'smtp_port'     => 465,
    'mailpath'      => 'C:\xampp\sendmail', // tried without sendmail
    'smtp_user'     => 'correct email',
    'smtp_pass'     => 'correct pass',
    'mailtype'      => 'html',
    'charset'       => 'utf-8',
    'starttls'      => true, // changing makes no difference
    'smtp_crypto'   =>'ssl', // tried without ssl on port 25 as wel, google not responding
    '_smtp_auth'    => true // tried removing this
);
$this->load->library('email', $config);
$this->email->from('tkd.tongil.neeroeteren@gmail.com', 'Tong-Il Neeroeteren'); //verzender (magic e-cards)
$this->email->to($email); //ontvanger
$this->email->subject($subject); //onderwerp toevoegen
//inhoud van het bericht met activatiecode als link.
$this->email->message($message);
if (!$this->email->send()) {
    $errors = $this->email->print_debugger();
    return false;
} else {
    return true;
}

$errors 中的信息总是一样的:

220 smtp.gmail.com ESMTP h11sm1190535ljh.15 - gsmtp
<br /><pre>hello: 250-smtp.gmail.com at your service, [2a02:1810:9d16:bf00:eda1:6150:23ed:ba70]
250-SIZE 35882577
250-8BITMIME
250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-CHUNKING
250 SMTPUTF8
</pre>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 h11sm1190535ljh.15 - gsmtp
<br /><pre>from: 530-5.5.1 Authentication Required. Learn more at
530 5.5.1  https://support.google.com/mail/?p=WantAuthError h11sm1190535ljh.15 - gsmtp
</pre>The following SMTP error was encountered: 530-5.5.1 Authentication Required. Learn more at
530 5.5.1  https://support.google.com/mail/?p=WantAuthError h11sm1190535ljh.15 - gsmtp
<br /><pre>to: 530-5.5.1 Authentication Required. Learn more at
530 5.5.1  https://support.google.com/mail/?p=WantAuthError h11sm1190535ljh.15 - gsmtp
</pre>The following SMTP error was encountered: 530-5.5.1 Authentication Required. Learn more at
530 5.5.1  https://support.google.com/mail/?p=WantAuthError h11sm1190535ljh.15 - gsmtp
<br /><pre>data: 530-5.5.1 Authentication Required. Learn more at
530 5.5.1  https://support.google.com/mail/?p=WantAuthError h11sm1190535ljh.15 - gsmtp
</pre>The following SMTP error was encountered: 530-5.5.1 Authentication Required. Learn more at
530 5.5.1  https://support.google.com/mail/?p=WantAuthError h11sm1190535ljh.15 - gsmtp
<br />502 5.5.1 Unrecognized command. h11sm1190535ljh.15 - gsmtp
<br />The following SMTP error was encountered: 502 5.5.1 Unrecognized command. h11sm1190535ljh.15 - gsmtp
<br />Unable to send email using PHP SMTP.  Your server might not be configured to send mail using this method.<br /><pre>User-Agent: CodeIgniter
Date: Mon, 10 Oct 2016 19:34:18 +0200
From: "Tong-Il Neeroeteren" <tkd.tongil.neeroeteren@gmail.com>
Return-Path: <tkd.tongil.neeroeteren@gmail.com>
To: robbie.vercammen@gmail.com
Subject: =?utf-8?Q?Activeer_uw_account?=
Reply-To: "tkd.tongil.neeroeteren@gmail.com" <tkd.tongil.neeroeteren@gmail.com>
X-Sender: tkd.tongil.neeroeteren@gmail.com
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <57fbd11ad5a9f@gmail.com>
Mime-Version: 1.0


Content-Type: multipart/alternative; boundary=&quot;B_ALT_57fbd11ad5b41&quot;

This is a multi-part message in MIME format.
Your email application may not support this format.

--B_ALT_57fbd11ad5b41
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit

// Too much info 

--B_ALT_57fbd11ad5b41
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable

// Too much info

--B_ALT_57fbd11ad5b41--</pre>

我的 php.ini

[mail function]
SMTP=ssl://smtp.gmail.com
smtp_port=465
sendmail_from = tkd.tongil.neeroeteren@gmail.com
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"
mail.add_x_header=On

还有我的 sendmail.ini

smtp_server=smtp.gmail.com
smtp_port=465
smtp_ssl=auto
auth_username=correct email
auth_password=correct password
force_sender=tkd.tongil.neeroeteren@gmail.com

我启用了不太安全的访问,并尝试了解锁验证码方法,但无济于事。 我如何让它在本地主机上工作。

一旦它被部署到我的托管域,我也不知道如何配置它。任何帮助将不胜感激

【问题讨论】:

    标签: php codeigniter email sendmail


    【解决方案1】:

    我找到了答案……

    这就是我最终使用的

    $config = Array(
            "protocol"      => "smtp",
            "smtp_host"     => "smtp.gmail.com",
            //"smtp_host"     => "localhost",
            "smtp_port"     => 587,
            "mailpath"      => "C:\\xampp\\sendmail",
            "smtp_user"     => "",
            "smtp_pass"     => "",
            "mailtype"      => "html",
            "charset"       => "ISO-8859-1",
            "starttls"      => true,
            "smtp_crypto"   =>"tls",
            "smpt_ssl"      => "auto",
            "send_multipart"=> false
        );
        $this->load->library('email', $config);
        $this->email->set_newline("\r\n");
        // rest remains the same
    

    我相信$this-&gt;email-&gt;set_newline("\r\n"); 是缺失的链接。为什么除了身份验证失败之外没有其他错误消息......我们永远不会知道。

    【讨论】:

      猜你喜欢
      • 2018-01-09
      • 2012-05-25
      • 2014-08-09
      • 2020-02-07
      • 1970-01-01
      • 2021-02-12
      • 1970-01-01
      • 2018-05-20
      • 1970-01-01
      相关资源
      最近更新 更多