function sendMail() {
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => '[email protected]',
'smtp_pass' => 'xxx',
'mailtype' => 'html',
'charset' => 'iso-8859-1',
'wordwrap' => TRUE
);
$message = 'test';
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$this->email->from('[email protected]');
$this->email->to('[email protected]');
$this->email->subject('testing');
$this->email->message($message);
if($this->email->send())
{
echo 'Email sent.';
}
else
{
show_error($this->email->print_debugger());
}
}
This is my code, i am trying to send email from localhost using codeigniter , i got message "Email sent." but i didnt got any mail in gmail account.
I see you are missing
$this->email->initialize($config);
Also make sure you have set up your email settings on you localhost else will not work.Also
$config = Array(
change to$config = array(
Replace Google Mail "gmail"
'smtp_host' => 'ssl://smtp.googlemail.com'
With
'smtp_host' => 'ssl://smtp.gmail.com'
Code