0

I am trying to send mail from localhost(LAMP) using codeigniter using the following code snippet. It shows "Email sent.". But the email is not received at my email address.

function sendMail() {
    $config = Array(
        'protocol'  => 'smtp',
        'smtp_host' => 'ssl://smtp.googlemail.com',
        'smtp_port' => 465,
        'smtp_user' => 'xxx@gmail.com', // change it to yours
        'smtp_pass' => 'xxx', // change it to yours
        'mailtype'  => 'html',
        'charset'   => 'iso-8859-1',
        'wordwrap'  => TRUE
    );

    $message = '';
    $this->load->library('email', $config);
    $this->email->set_newline("\r\n");
    $this->email->from('xxx@gmail.com'); // change it to yours
    $this->email->to('xxx@gmail.com'); // change it to yours
    $this->email->subject('testing');
    $this->email->message($message);
    if($this->email->send()) {
        echo 'Email sent.';
    }
    else {
        show_error($this->email->print_debugger());
    }
}
Peladao
  • 4,036
  • 1
  • 23
  • 43
mridul
  • 1,986
  • 9
  • 29
  • 50

3 Answers3

3

change, 'smtp_host' => 'ssl://smtp.googlemail.com', To $config['smtp_host'] = "ssl://smtp.gmail.com";

Reena Shirale
  • 1,992
  • 1
  • 17
  • 15
0

I had the same issue , I switched to Free Email emgine Mailenter link description heretrap which is free - and it doesnt flood our inbox will all test email , all you need to do is just sign up and use its smtp Details .

I have lib you want to use its api

jai
  • 541
  • 5
  • 8
0

In my case on protocols mail/sendmail/tls working without any error in a server with CodeIgniter but I didn't get mail and no error. How would I know what's the problem and in case of smtp protocols it gave an error.

heySushil
  • 493
  • 7
  • 13