Reputation: 4869
I am using codeigniter and its email class to try sending a email on MAMP (free version)
My code is as below
$config = Array(
'protocol' => 'smtp', 'smtp_host' => 'ssl://smtp.googlemail.com', 'smtp_port' => 465, 'smtp_user' => '[email protected]', 'smtp_pass' => '*********', 'mailtype' => 'html', 'starttls' => true ); $this->load->library('email', $config); $this->email->set_newline("\r\n"); $this->email->from('[email protected]', 'Jeffrey Way'); $this->email->to('[email protected]'); $this->email->subject('This is an email test'); $this->email->message('It is working. Great!'); $this->email->send(); echo $this->email->print_debugger();
However I always get an error
220 mx.google.com ESMTP ri1sm17015935pbc.16 - gsmtp hello: 250-mx.google.com at your service, [203.116.128.34] 250-SIZE 35882577 250-8BITMIME 250-AUTH LOGIN PLAIN XOAUTH XOAUTH2 250 ENHANCEDSTATUSCODES
Failed to authenticate password. Error: 535-5.7.1 Username and Password not accepted. Learn more at 535 5.7.1 http://support.google.com/mail/bin/answer.py?answer=14257 ri1sm17015935pbc.16 - gsmtp from: 530-5.5.1 Authentication Required. Learn more at 530 5.5.1 http://support.google.com/mail/bin/answer.py?answer=14257 ri1sm17015935pbc.16 - gsmtp
The following SMTP error was encountered: 530-5.5.1 Authentication Required. Learn more at 530 5.5.1 http://support.google.com/mail/bin/answer.py?answer=14257 ri1sm17015935pbc.16 - gsmtp to: 530-5.5.1 Authentication Required. Learn more at 530 5.5.1 http://support.google.com/mail/bin/answer.py?answer=14257 ri1sm17015935pbc.16 - gsmtp
Thanks in advance for the help.
Upvotes: 1
Views: 446
Reputation: 2200
I have seen this question asked in numerous places, and of course, I am here because I have the same problem. I think what's going on is that when Jeffrey Way wrote the tutorial (Day 3, exactly where I got my code from) in 2009, the authentication to send an email was pretty straight forward. I think it's different now with Google. You have to use an oauth2 authentication flow. I have managed to find such a code for CodeIgniter, and can authenticate, but I still don't quite understand what to do after authentication. I probably haven't tried hard enough, since of late I have been writing several oAuth2 authentication scripts for Google, Yahoo, Facebook, Twitter, and Flickr. I'm guessing that after you allow the app to access your Google info, the callback page is where you put your actual sendmail code (the code you have in your question). So, I think it is a two-part process:
You just want to simply send an email, I realize, and so do I. But I think you might want to copy & paste & try this working script:
Login with google account in codeigniter
Upvotes: 0
Reputation: 49873
Authentication Required.
you are using not your own gmail account (email and password)
Upvotes: 0