从本地服务器发送邮件时出错

时间:2017-11-09 13:35:19

标签: php codeigniter email gmail wamp

我正在尝试使用我的gmail帐户从我的本地wamp服务器(os是windows 10)在codeigniter 3中测试一个简单的联系表单。我以前做了很多次,但现在我得到了一个错误。我已经阅读了关于这个主题的所有Stack线程,但他们只是告诉我做我已经在做的事情而且它不起作用。我联系了Google,但他们也告诉我要做我已经做的事情。

我已经设置了我的控制器:

        $config = array(
            'protocol'=>'smtp',
            'smtp_host'=>'ssl://smtp.gmail.com',
            'smtp_port'=>465,
            'smtp_user'=>'username@gmail.com',
            'smtp_pass'=>'password',
            'mailtype'=>'text',
            'charset'=>'iso-8859-1',
            'smtp_timeout'=>'30',
            'crlf'=>'r\n',
            'newline'=>'r\n',
            'wordwrap'=>TRUE
        );
        $this->load->library('email',$config);

php.ini配置正确我相信。我已在我的Gmail帐户中启用了“允许安全性较低的应用”,并且两步验证已关闭。但我仍然得到这个错误:

220 smtp.gmail.com ESMTP b36sm5736977edd.67 - gsmtp

hello: 250-smtp.gmail.com at your service, [86.180.98.185]
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: 535-5.7.8 Username and Password not accepted. Learn more at 535 5.7.8 https://support.google.com/mail/?p=BadCredentials b36sm5736977edd.67 - gsmtp
Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.

User-Agent: CodeIgniter
Date: Thu, 9 Nov 2017 10:22:00 +0000
From: "Mike Heath" <msheath@btinternet.com>
Return-Path: <msheath@btinternet.com>
To: mike24heath@gmail.com
Subject: =?ISO-8859-1?Q?=43=6F=6E=74=61=63=74=20=4D=65=73=73=61=67=65?=
Reply-To: <msheath@btinternet.com>
X-Sender: msheath@btinternet.com
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <5a042c4818341@btinternet.com>
Mime-Version: 1.0


Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit

我确信我的用户名/密码是正确的,因为我可以使用它们登录gmail。什么可能出错?感谢任何想法。

1 个答案:

答案 0 :(得分:0)

我刚刚发现了测试邮件服务器工具,这是我所有电子邮件测试问题的完整答案。忘记Sendmail,PHPMailer,Gmail等 http://www.toolheap.com/test-mail-server-tool/