0
votes

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'] = "[email protected]";
                $config['smtp_pass'] = "";
                $config['charset'] = "utf-8";
                $config['mailtype'] = "html";
                $config['newline'] = "\r\n";

                $ci->email->initialize($config);
                $ci->email->from('[email protected]', 'Blabla');
                $list = array('[email protected]');
                $ci->email->to($list);
                $this->email->reply_to('[email protected]', '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: [email protected] 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: [email protected] X-Mailer: CodeIgniter X-Priority: 3 (Normal) Message-ID: <[email protected]> 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.

1
Change smtp_host to 'ssl://smtp.googlemail.com'. See here stackoverflow.com/questions/1555145/…carlosdubusm
not working, i tried all , it says the same error.Sam

1 Answers

0
votes

Change these

$config['smtp_host'] = "ssl://smtp.googlemail.com"; # Change
$config['smtp_port'] = "465";
$config['smtp_user'] = "[email protected]";
$config['smtp_pass'] = ""; # Your account password