SMTP on CodeIgniter shows success, but e-mail is not delivered to Gmail account
Change it to the following:
$ci = get_instance();$ci->load->library('email');$config['protocol'] = "smtp";$config['smtp_host'] = "ssl://smtp.gmail.com";$config['smtp_port'] = "465";$config['smtp_user'] = "blablabla@gmail.com"; $config['smtp_pass'] = "yourpassword";$config['charset'] = "utf-8";$config['mailtype'] = "html";$config['newline'] = "\r\n";$ci->email->initialize($config);$ci->email->from('blablabla@gmail.com', 'Blabla');$list = array('xxx@gmail.com');$ci->email->to($list);$this->email->reply_to('my-email@gmail.com', 'Explendid Videos');$ci->email->subject('This is an email test');$ci->email->message('It is working. Great!');$ci->email->send();
replace
$config['protocol'] = 'smtp';
to
$config['protocol'] = 'sendmail';
here is work for me on apache2 server, ci 2.1.4: its very simple:first create a file called email.php under your application/config directory then type the following code inside them~>
<?php$config['protocol'] = 'smtp';$config['smtp_host'] = 'ssl://smtp.gmail.com';$config['smtp_port'] = '465';$config['smtp_user'] = 'u'r gmail account';$config['smtp_pass'] = 'password of u'r account';$config['charset'] = 'utf-8';$config['newline'] = "\r\n";?>
then create a file called email.php under your application/controllers directory then type this code~>
<?php class Email extends CI_Controller { function send() { // Loads the email library $this->load->library('email'); // FCPATH refers to the CodeIgniter install directory // Specifying a file to be attached with the email // if u wish attach a file uncomment the script bellow: //$file = FCPATH . 'yourfilename.txt'; // Defines the email details $this->email->from('some@of.mailaddress', 'ur Name'); $this->email->to('email@detiny.your'); $this->email->subject('Email Test'); $this->email->message('Testing the email class.'); //also this script //$this->email->attach($file); // The email->send() statement will return a true or false // If true, the email will be sent if ($this->email->send()) { echo "you are luck!"; } else { echo $this->email->print_debugger(); } } } ?>