Welcome Guest, Not a member yet? Register   Sign In
Integrate Google Apps Mail with CodeIgniter - Error
#1

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

Attached Files
.txt   Email Err.txt (Size: 1.55 KB / Downloads: 150)
Reply
#2

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.
Reply
#3

(05-27-2016, 03:50 AM)Aneri Wrote: 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
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.
Reply
#4

(05-27-2016, 09:15 AM)PaulD Wrote:
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.

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.
Reply
#5

https://support.google.com/accounts/answer/6010255
Keep calm.
Reply
#6

(05-28-2016, 01:22 AM)arma7x Wrote: https://support.google.com/accounts/answer/6010255

Already done that. So that is not the reason.
Reply
#7

(This post was last modified: 05-28-2016, 05:45 AM by arma7x.)

PHP Code:
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'smtp.gmail.com';
$config['smtp_user'] = '[email protected]';
$config['smtp_pass'] = 'mypassword';
$config['smtp_port'] = 465;
$config['smtp_crypto'] = 'ssl; 

This is my CI email configuration using gmail account. Result :: successfully send email. Make sure to follow all instruction from google troubleshoot.
Keep calm.
Reply
#8

It is working for me like this:


Code:
[
    'protocol'     => 'smtp',
    'smtp_host'    => 'ssl://smtp.gmail.com',
    'smtp_port'    => '465',
    'smtp_user'    => '[email protected]',
    'smtp_pass'    => 'mypassword',
    'smtp_timeout' => '30',
]

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
Reply
#9

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.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB