I am using MAMP and CodeIgniter 2.1.3(the latest) and trying to send an email. I have read various tutorials and as far as I can see my code has no errors in it. I need some help deciphering where the problem is as every time I run the function, local or when I have uploaded it, I receive only a blank page. Nothing is being printed on screen at all.
I have tried setting out the $config
array both ways I know and nothing changes. I.e. $config['protocol'] = 'smtp';
and $config = Array( 'protocol' => 'smtp', 'smtp_host => 'ssl://smtp.googlemail.com');
I can't understand why its not working, I've been through the email library and I have all the config written right. Is there some syntax error that I cannot see?
<?php
class Email extends CI_Controller
{
function __construct()
{
parent::Controller();
}
function index()
{
$config['protocol'] = 'smtp';
$config['mail_path'] = 'ssl://smtp.googlemail.com';
$config['smtp_host'] = 'ssl://smtp.googlemail.com';
$config['smtp_port'] = 465;
$config['smtp_user'] = 'MYEMAIL@gmail.com'
$config['smtp_pass'] = 'PASSWORD';
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$this->email->from('MYEMAIL@gmail.com', 'THIS GUY');
$this->email->to('MYEMAIL@gmail.com');
$this->email->subject('Email test bitches');
$this->email->message('This is working, I hope');
if($this->email->send())
{
echo "Da email, da email, wut wut da emails";
}else{
show_error($this->email->print_debugger());
}
}
}
The error that I have got to print on screen is as follows
Parse error: syntax error, unexpected '$config' (T_VARIABLE) in /Applications/MAMP/htdocs/codeigniter/application/controllers/email.php on line 18
So then I saw that it lacked a ;
and I put it in but now the page doesn't load :/. Added ssl://
and now I have an error report from Google. At least I can work with this.
Thank you :)