sending email in CodeIgniter through gmail
codeigniter, mamp
Solution
in your php.ini file uncomment extension=php_openssl.dll
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => '465',
'smtp_user' => 'someuser@gmail.com',
'smtp_pass' => 'password',
'mailtype' => 'html',
'starttls' => true,
'newline' => "\r\n"
);
$this->load->library('email', config);
$this->email->from('email@gmail.com', 'George');
$this->email->to('email@gmail.com');
$this->email->subject('hey this is an email');
$this->email->message('this is the content of the email');
$this->email->send();
echo $this->email->print_debugger();
Hope this will work
Problem
I'm following a tutorial to send emails using gmail, however what I get is a page that just hangs and doesn't even load an error. I'm using MAMP so that may be a reason why it isnt working. ``` class Email extends CI_Controller{ public function __construct() { parent::__construct(); } function index(){ $config = Array( 'protocol' => 'smtp', 'smtp_host' => 'ssl://smtp.googlemail.com', 'smtp_port' => 465, 'smtp_user' => 'email', 'smtp_pass' => 'pass' ); $this->load->library('email',$config); $this->email->set_newline("/r/n"); $this->email->from('email', 'George'); $this->email->to('email'); $this->email->subject('hey this is an email'); $this->email->message('this is the content of the email'); if($this->email->send()){ echo 'Your message was sent'; }else{ show_error($this->email->print_debugger()); } } } ```