Search code examples
phpcodeigniteremailgmailwamp

Error sending email from local server


I am trying to test a simple contact form in codeigniter 3 from my local wamp server (os is windows 10) using my gmail account. I have done this many times before but now I get an error. I have read all Stack threads on the subject but they just tell me to do what I am already doing and it isn't working. I have contacted Google but they are also telling me to do what I am already doing.

I have set up my controller like this:

        $config = array(
            'protocol'=>'smtp',
            'smtp_host'=>'ssl://smtp.gmail.com',
            'smtp_port'=>465,
            'smtp_user'=>'[email protected]',
            '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 is configured correctly I believe. I have turned on 'Allow less secure apps' in my Gmail account and 2-step verification is off. But I still get this error:

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" <[email protected]>
Return-Path: <[email protected]>
To: [email protected]
Subject: =?ISO-8859-1?Q?=43=6F=6E=74=61=63=74=20=4D=65=73=73=61=67=65?=
Reply-To: <[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=ISO-8859-1
Content-Transfer-Encoding: 8bit

I am confident that my username/password are correct because I can use them to log in to gmail. What could possibly be going wrong? Grateful for any ideas.


Solution

  • I have just discovered the Test Mail Server Tool which is the complete answer to all my email test problems. Forget Sendmail, PHPMailer, Gmail etc http://www.toolheap.com/test-mail-server-tool/