1

I'm running into an error when trying to send an email using codeigniter. I've tested the function I'm using with an online server but it still throws the same error.

Below is my function:

//send email
    function sendEmail() {
        $config = Array(
            'protocol' => 'smtp',
            'smtp_host' => 'ssl://smtp.googlemail.com',
            'smtp_port' => 465,
            'smtp_user' => 'email', // change it to yours
            'smtp_pass' => 'pswd', // change it to yours
            'mailtype' => 'html',
            'charset' => 'iso-8859-1',
            'wordwrap' => TRUE
        );

        $message = 'Test message';
        $this->load->library('email', $config);
        $this->email->set_newline("\r\n");
        $this->email->from('zzz@gmail.com'); // change it to yours
        $this->email->to('xxx@gmail.com'); // change it to yours
        $this->email->subject('Resume from JobsBuddy for your Job posting');
        $this->email->message($message);
        if ($this->email->send()) {
            echo 'Email sent.';
        } else {
            show_error($this->email->print_debugger());
        }
    }

I'm getting the below error:

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 w84sm8590284ioi.20 - gsmtp Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.

Kindly assist

AJ X.
  • 2,729
  • 1
  • 23
  • 33
Kabs
  • 227
  • 2
  • 4
  • 12
  • Did you change this both ?? `'smtp_user' => 'email', 'smtp_pass' => 'pswd',` – Abdulla Nilam Jan 09 '16 at 19:47
  • It's exactly what it says. You need to edit your Google account settings to permit access to smtp. – AJ X. Jan 09 '16 at 19:48
  • 1
    Possible duplicate of [How to configure XAMPP to send mail from localhost?](http://stackoverflow.com/questions/15965376/how-to-configure-xampp-to-send-mail-from-localhost) –  Jan 09 '16 at 19:51
  • From Google help: Sign in to the Gmail web interface.Open the 'Forwarding and POP/IMAP' tab on your 'Settings' page, and configure IMAP or POP. After enabling this in Gmail, make sure you click 'Save Changes' so Gmail can communicate with your mail client – AJ X. Jan 09 '16 at 19:56
  • @aaronxxx this question is diferent from your flag. Recast vote – Abdulla Nilam Jan 09 '16 at 19:56
  • This might help https://www.youtube.com/watch?v=TO7MfDcM-Ho –  Jan 09 '16 at 20:00
  • Check this as well http://stackoverflow.com/a/30610643/4595675 – Abdulla Nilam Jan 09 '16 at 20:00
  • Thanks alot, it was an issue with settings in the gmail account I was using – Kabs Jan 09 '16 at 20:02
  • 1
    @apdulla look at the title.. –  Jan 09 '16 at 20:09
  • @axlj in title is xampp –  Jan 09 '16 at 20:27

1 Answers1

0

The answer isn't code related but due to the fact that your Gmail account must be enabled to permit smtp/IMAP access. From the Google help Center:

  1. Sign in to the Gmail web interface.
  2. Open the 'Forwarding and POP/IMAP' tab on your 'Settings' page, and configure IMAP or POP.
  3. After enabling this in Gmail, make sure you click 'Save Changes' so Gmail can communicate with your mail client
AJ X.
  • 2,729
  • 1
  • 23
  • 33