1

hello Guys can anyone help me to this error Sending email using codeigniter EMAIL CLASS My problem is email sending is not working On live server on Hostinger But On local host XAMPP they work using Codeigniter Email library But On live did not working HERE IS MY ERROR DISPLAY ON RESPONSE

    <div id="container">
        <h1>An Error Was Encountered</h1>
        <p>220 smtp.gmail.com ESMTP q9sm5357266wrd.57 - gsmtp
<br /><pre>hello: 250-smtp.gmail.com at your service, [2a02:4780:a::9]
250-SIZE 35882577
250-8BITMIME
250-STARTTLS
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-CHUNKING
250 SMTPUTF8
</pre><pre>starttls: 220 2.0.0 Ready to start TLS
</pre><pre>hello: 250-smtp.gmail.com at your service, [2a02:4780:a::9]
250-SIZE 35882577
250-8BITMIME
250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-CHUNKING
250 SMTPUTF8
</pre>Failed to authenticate password. Error: 534-5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbu
534-5.7.14 xFZbjKc3qJqbPzRmoF-qrBcojBiV4zi1yh2AdP_X-JmSPkPlo99C_Mrx-1gC-zLhYuRao
534-5.7.14 ldCCUp2nLIELg8oYFv-KQUZQrXbrBs3PO3g4n903OObkXvtKwkT6jN5Bra27WagB>
534-5.7.14 Please log in via your web browser and then try again.
534-5.7.14  Learn more at
534 5.7.14  https://support.google.com/mail/answer/78754 q9sm5357266wrd.57 - gsmtp
<br />Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.<br /><pre>Date: Sun, 4 Oct 2020 18:20:29 +0800
To: marvennizonsuson@gmail.com
From: &quot;Administrator&quot; &lt;admin@nvac.edu.ph&gt;
Return-Path: &lt;admin@nvac.edu.ph&gt;
Subject: =?UTF-8?Q?User=20Login=20Account=20for=20NVAC=20School?=
Reply-To: &lt;admin@nvac.edu.ph&gt;
User-Agent: CodeIgniter
X-Sender: admin@nvac.edu.ph
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: &lt;5f79a1ed24294@nvac.edu.ph&gt;
Mime-Version: 1.0


Content-Type: multipart/alternative; boundary=&quot;B_ALT_5f79a1ed242a9&quot;

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

--B_ALT_5f79a1ed242a9
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Your User login Account For NVAC PORTAL
 Your username :marvennizonsuson@gmail.com And Password : urjdC9NkeE


--B_ALT_5f79a1ed242a9
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

&lt;h1&gt;Your User login Account For NVAC PORTAL&lt;/h1&gt;=0A  &lt;p&gt; Your username :mar=
vennizonsuson@gmail.com And Password : urjdC9NkeE &lt;/p&gt;

--B_ALT_5f79a1ed242a9--</pre></p>   </div>

HERE IS MY PHP CODE ON CONTROLLER IN CODEIGNITER

public function Mailer($email,$pass,$data){
  //Load email library
// $this->load->library('encrypt');
  //SMTP & mail configuration
    $smtp = true;
$this->load->library('email');
if($smtp){
      $config = array(
      'protocol'  => 'smtp',
      'mailpath' => "/usr/sbin/sendmail", /// ill try to remove this but did not worked
      'smtp_host' => 'smtp.gmail.com', //optional smtp.hostinger.ph
      'smtp_port' => 587,
      'smtp_user' => 'marvennkhulets@example.com',
      'smtp_pass' => 'mysecurepass',
      'charset'   => 'utf-8',
      'mailtype'  => 'html',
      'starttls'  => true,
      'smtp_crypto' => 'tls',
      'newline'   => "\r\n",
      'crlf' => "\r\n"
  );
}else{
    $config['protocol'] = 'sendmail';
$config['mailpath'] = '/usr/sbin/sendmail';
$config['charset'] = 'iso-8859-1';
$config['wordwrap'] = TRUE;
}


  $this->email->initialize($config);

  $this->email->set_mailtype("html");
  $this->email->set_newline("\r\n");

  //Email content

     
  $htmlContent = "<h1>Your User login Account For NVAC PORTAL</h1>
  <p> Your username :$email And Password : $pass </p>";

  $this->email->to($email);
  $this->email->from('admin@nvac.edu.ph','Administrator');
  $this->email->subject('User Login Account for NVAC School');
  $this->email->message($htmlContent);

  //Send email
  if($this->email->send()){
    $json['response'] = "true";
     $this->Teacher_model->insertCredentialsTeacher($data);
  }else{
         $this->Teacher_model->insertCredentialsTeacher($data);
    $json['response'] = "false";
      $json['message'] = show_error($this->email->print_debugger());
  }

       echo json_encode($json);


}

0 Answers0