0

Hi guys i am trying to send an email to myself for testing purpose . I have hosted website over cpanel and i am using Codeigniter libraries to send email.

This is my code in my controller

 $config = array();
// $config['useragent']           = "CodeIgniter";
$config['mailpath']            = "/usr/sbin/sendmail"; 
$config['protocol']            = "smtp";
$config['smtp_host']           = "ssl://smtp.googlemail.com";
$config['smtp_port']           = "465";
$config['smtp_user']="myemail@gmail.com";  
$config['smtp_pass']="mypass";
//  $config['mailtype'] = 'html';
//  $config['charset']  = 'utf-8';
// $config['newline']  = "\r\n";
//  $config['wordwrap'] = TRUE;

$this->load->library('email');

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


    $this->email->from('myemail@gmail.com', 'xyz');
    $this->email->to('myemail@gmail.com');

    $this->email->subject('Email Test');
    $this->email->message('Testing the email class.');

    if($this->email->send())
    {
    echo 'Email send.';
    }
    else
    {
    show_error($this->email->print_debugger());
    }

And this is the error that i am getting

20 smtp.googlemail.com ESMTP q194sm1834461pfq.43 - gsmtp

hello: 250-smtp.googlemail.com at your service, [43.225.55.90]
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 q194sm1834461pfq.43 - 
gsmtp
Unable to send email using PHP SMTP. Your server might not be configured 
to send mail using this method.

Please help me out here . Really confused on how the process should be . Thanks in advance

jerome
  • 1
  • 1
  • 5
  • Possible duplicate of [Sending email with gmail smtp with codeigniter email library](http://stackoverflow.com/questions/1555145/sending-email-with-gmail-smtp-with-codeigniter-email-library) – Jerzyk Feb 28 '17 at 07:55
  • Are you still facing that issue –  Feb 28 '17 at 08:32
  • yes i am still facing the issue – jerome Feb 28 '17 at 09:00
  • what should be the value of config['smtp_host '] ? – jerome Feb 28 '17 at 09:02
  • @Jerzyk i have referred to that link but the solution does not work for me . I am getting the same error. Is there any other setting that i need to make in codeigniter ? – jerome Feb 28 '17 at 09:09
  • do a simple SMTP test on your server to see whether openssl is working – qwertzman Feb 28 '17 at 11:16

0 Answers0