0

I have Been try to send Mail using Codeigniter 3.0 .

My Controller :

function index()
    {

              $ci = get_instance();
                $ci->load->library('email');
                $config['protocol'] = "smtp";
                $config['smtp_host'] = "ssl://smtp.gmail.com";
                $config['smtp_port'] = "465";
                $config['smtp_user'] = "sriramarvind95@gmail.com";
                $config['smtp_pass'] = "";
                $config['charset'] = "utf-8";
                $config['mailtype'] = "html";
                $config['newline'] = "\r\n";

                $ci->email->initialize($config);
                $ci->email->from('sriramarvind95@gmail.com', 'Blabla');
                $list = array('skarthikeyan1410@gmail.com');
                $ci->email->to($list);
                $this->email->reply_to('sriramarvind95@gmail.com', 'Explendid Videos');
                $ci->email->subject('This is an email test');
                $ci->email->message('It is working. Great!');
                $result=$ci->email->send();

                if($result){
                    $data['email']="sent";
                }
                else{
                    $data['email']="not Sent";
                }
        //echo $this->email->print_debugger();
        $this->load->view('welcome_message',$data);

my view

<?php
if ($email="not Sent"){
    echo $this->email->print_debugger();
}
else{
    echo "Sent";
}

?>

Other than this,i configured my gmail account to allow less apps to login into gmail.

yet i get this error :

220 smtp.gmail.com ESMTP p10sm8628622obk.11 - gsmtp hello: 250-smtp.gmail.com at your service, [23.102.172.97] 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: 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 p10sm8628622obk.11 - gsmtp Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method. User-Agent: CodeIgniter Date: Mon, 11 Apr 2016 13:17:26 -0700 From: "Blabla" Return-Path: To: skarthikeyan1410@gmail.com Reply-To: "Explendid Videos" Subject: =?utf-8?Q?=54=68=69=73=20=69=73=20=61=6E=20=65=6D=61=69=6C=20=74=65=73=74?= X-Sender: sriramarvind95@gmail.com X-Mailer: CodeIgniter X-Priority: 3 (Normal) Message-ID: <570c06564edde@gmail.com> Mime-Version: 1.0

Content-Type: multipart/alternative; boundary="B_ALT_570c06564edf2"

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

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

It is working. Great!

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

It is working. Great=21

--B_ALT_570c06564edf2--

Trying this is in hosted service , not in localhost.

i have no clue , i use plain text in my password field . is it correct or should i generate something.

Please help.

Sam
  • 1
  • 3
  • 3
    Change smtp_host to 'ssl://smtp.googlemail.com'. See here http://stackoverflow.com/questions/1555145/sending-email-with-gmail-smtp-with-codeigniter-email-library – carlosdubusm Apr 11 '16 at 20:38
  • not working, i tried all , it says the same error. – Sam Apr 12 '16 at 11:04

1 Answers1

0

Change these

$config['smtp_host'] = "ssl://smtp.googlemail.com"; # Change
$config['smtp_port'] = "465";
$config['smtp_user'] = "sriramarvind95@gmail.com";
$config['smtp_pass'] = ""; # Your account password 
Abdulla Nilam
  • 36,589
  • 17
  • 64
  • 85