Reputation: 9049
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());
}
}
}
Upvotes: 4
Views: 3179
Reputation: 9
MAMP does not ship with the openssl extension, but you can create it yourself. For details see this tutorial
Upvotes: 0
Reputation: 465
Start by posting using the standard smtp ports and make sure that works using the config below:
function index(){
$config = Array( 'protocol' => 'smtp', 'smtp_host' => 'smtp.googlemail.com', 'smtp_port' => 25, 'smtp_user' => 'email', 'smtp_pass' => 'pass' );
$this->load->library('email',$config);
$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');
$this->email->send(); }
Once you've tried that and it's all working have a read through this:
http://codeigniter.com/forums/viewthread/84689/
Upvotes: -1
Reputation: 10996
I just did this successfully myself, but through sending all values in config/email.php instead. That part shouldn't matter.
Well basicly are you trying to send through a @gmail account or your own domain? If you're trying to go through your own domain, you need to change the DNS to relevant google settings:
Upvotes: 0
Reputation: 8461
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' => '[email protected]',
'smtp_pass' => 'password',
'mailtype' => 'html',
'starttls' => true,
'newline' => "\r\n"
);
$this->load->library('email', config);
$this->email->from('[email protected]', 'George');
$this->email->to('[email protected]');
$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
Upvotes: 7
Reputation: 1694
The line causing problems is:
$this->email->set_newline("/r/n");
Remove it and try sending the email.
Upvotes: 0