mathew hadden
mathew hadden

Reputation: 21

SMTP send mail by codeigniter

I try to send mail using SMTP using codeigniter. But get following problem. Even my credential is correct and work fine while i opened in gmail. After that I got below message.

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" <[email protected]>
 Return-Path: <[email protected]>
 To: [email protected]
 Subject: =?utf-8?Q?Welcome_for_new_signup?=
 Reply-To: "[email protected]" <[email protected]>
 X-Sender: [email protected]
 X-Mailer: CodeIgniter
 X-Priority: 3 (Normal)
 Message-ID: <[email protected]>
 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.

Upvotes: 0

Views: 2436

Answers (2)

Vaibhav Malushte
Vaibhav Malushte

Reputation: 171

You must change $config['protocol'] = "smtp"; to $config['protocol'] = "SMTP";

Let me know if it works for you

Upvotes: 5

Raham
Raham

Reputation: 4951

Try the following code,may it fixed your issue.It worked perfect for me.

$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("[email protected]");
$this->email->to("[email protected]");
$this->email->send();

Upvotes: 0

Related Questions