gobi
gobi

Reputation: 117

SMTP mailer is not working in codeignitor 3

Failed to authenticate password. Error: 535 Incorrect authentication data Unable to send email uenter code heresing PHP SMTP. Your server might not be configured to send mail using this method.

$config = Array(
  'protocol' => 'smtp',
  'smtp_host' => 'mail.******.com',
  'smtp_port' => 587,
  'smtp_user' => 'tracker@******.com', 
  'smtp_pass' => '7Wj{S******KU{', 
  'mailtype' => 'html',
  'charset' => 'iso-8859-1',
  'wordwrap' => TRUE
);

$message = 'Hiii';

       $this->load->library('email', $config);
        $this->email->set_newline("\r\n");
        // $this->load->library('email');
      $this->email->from('tracker@******.com'); // change it to yours

      $this->email->to($usremail);// change it to yours 

      $this->email->cc('');
      // $this->email->bcc('gobinath@******.com');
      $this->email->subject('hi');

      $this->email->message($message);

      $mailsucc = $this->email->send();
    if ($mailsucc) {
        echo "suc";
    exit();
    }else{
    $de = $this->email->print_debugger();
    print_r($de);
    exit();
    }

Upvotes: 0

Views: 123

Answers (1)

Andres Rave
Andres Rave

Reputation: 53

I've been looking for a while, and finally I get it. I hope this works for you too.

  1. Define your timezone:
    php timezone
    date_default_timezone_set('America/Bogota');

  2. Set up your email account to allow IMAP access, and allow email to be used in less secure applications
    less secure apps
    IMAP Access

  3. Set up your mail server with codeigniter:
    $this->load->library('email'); $config['protocol'] = 'smtp'; $config['smtp_host'] = 'smtp.gmail.com'; $config['smtp_user'] = '[email protected]'; $config['smtp_pass'] = 'xxxxxxxxxxx'; $config['smtp_port'] = 465; (465/587) $config['charset'] = 'utf-8'; $config['crlf'] = "\r\n"; $config['smtp_crypto'] = 'ssl'; (SSL/TSL) $this->email->initialize($config); $this->email->set_newline("\r\n");

  4. Prepare your mail to send:
    $this->email->from('[email protected]', 'ANY-NAME'); $this->email->to('[email protected]'); $this->email->subject('Email Test'); $this->email->message('Testing the email class.'); if($this->email->send()){ echo "sent"; } else{ echo $this->email->print_debugger(); }

Upvotes: 0

Related Questions