Reputation: 2162
I am developing web service for my android app and I am having a hard time on my email function to work well. I follow this tutorial HERE.
and in my controller I have this :
function forgotPassword_get(){
$this->load->model('model');
$this->response->format = 'json';
$email = $this->get('email');
$config['protocol'] = 'sendmail';
$config['mailpath'] = '/usr/sbin/sendmail';
$config['charset'] = 'iso-8859-1';
// gmail specific settings here
$config['smtp_host'] = 'smtp.gmail.com';
$config['smtp_user'] = 'my email here';
$config['smtp_pass'] = 'password here';
$config['smtp_port'] = '465';
$config['wordwrap'] = TRUE;
$this->load->library('email');
$this->email->initialize($config);
$this->email->from('mailfrom', 'sample name');
$this->email->to('mailto');
$this->email->subject('sample email');
$this->email->message('sample message for email.');
$this->email->send();
echo $this->email->print_debugger();
}
the result is
Your message has been successfully sent using the following protocol: sendmail
User-Agent: CodeIgniter
Date: Tue, 29 Oct 2013 15:45:57 +0800
From: "sample name"
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <[email protected]>
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
sample message for email.
it says the email is successfully sent, but I think mails not reaching my inbox.
could anyone help me, I think I'm missed something. thanks in advance.
Upvotes: 2
Views: 1051
Reputation: 1170
You might want to try this one:
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'ssl://smtp.googlemail.com';
$config['smtp_port'] = '465';
$config['smtp_user'] = '[email protected]';
$config['smtp_pass'] = 'password Here';
$config['charset'] = 'utf-8';
$config['mailtype'] = 'html';
$config['newline'] = "\r\n";
$this->load->library('email');
$this->email->initialize($config);
i just altered your config items. Hope it helps.
Upvotes: 2
Reputation: 153
Did you enable SMTP access in Gmail, if i remember correctly you have to click on some checkbox in Gmail like "Allow 3rd party to use this account for sending mail". Also this is not good practice because Gmail will constantly warn you that someone tries to access your account.
Upvotes: 0