Integrate Google Apps Mail with CodeIgniter - Error |
Hello,
I am developing a web app. The config details of the same are as follows: Domain - BigRock SMTP : Google Apps configured in BigRock Domain App server - EC2 , Redhat Linux Website - Developed in PHP using MVC architecture based on CodeIgniter. CodeIgniter has been already installed on the app server and is working for fine for everything else. I am running a simple file to test email : public function sendmail() { $config = Array( 'protocol' => 'smtp', 'smtp_host' => 'ssl://smtp.gmail.com', 'smtp_port' => 465, 'smtp_user' => '[email protected]', 'smtp_pass' => '<<our correct pwd>>', 'mailtype' => 'html', 'charset' => 'iso-8859-1' ); $this->load->library('email', $config); $this->email->set_newline("\r\n"); $this->email->from('[email protected]', 'sender name'); $this->email->to('[email protected]'); $this->email->cc('[email protected]'); $this->email->subject('Email Testing'); $this->email->message('Email Working'); if ($this->email->send()) echo "Mail Sent!"; else echo "There is error in sending mail!"; echo $this->email->print_debugger(); } But I am getting and error as provided in attachment. Can you tell me where we are going wrong? Thanks Code: Failed to authenticate password. It is in your error file. Also, if you are sending your email as HTML you have to send a full HTML page as the email body. (05-27-2016, 03:50 AM)Aneri Wrote: Hello,Here the instruction link i error files https://support.google.com/mail/answer/78754. Im also got this problem before, but with sailsjs. The problem not with Codeigniter, just follow the instruction in the link.
Keep calm.
(05-27-2016, 09:15 AM)PaulD Wrote: Well the password is not the problem. I am logged into the same account and checked it mutiple times. I am using the correct one in the code. But authentication is a problem, hence the error. (05-28-2016, 01:22 AM)arma7x Wrote: https://support.google.com/accounts/answer/6010255 Already done that. So that is not the reason. PHP Code: $config['protocol'] = 'smtp'; This is my CI email configuration using gmail account. Result :: successfully send email. Make sure to follow all instruction from google troubleshoot.
Keep calm.
It is working for me like this:
Code: [ If you still can't send mail, you have to tell Google that you want to use a less secure app: https://support.google.com/accounts/answ...0255?hl=en
Hello,
Thanks for all your help. There was a config file entry in the email.php in the controller config folder. Since I am new to PHP and CodeIgniter both I didn't knew that $this->load->library('email', $config); Was loading the email.php settings. Ideally the email.php data should have been overwritten by $config but is was not. Now I have staright away put the config details in the email.php and using the line $this->load->library('email') And it is working fine with and without the less secure apps setting in google admin. |
Welcome Guest, Not a member yet? Register Sign In |