I am a novice to CI and PHP. Currently I'm using xammp to run PHP, Apache and MySql. Now I am trying to send an email with CI. But I constantly got an error as below.
A PHP Error was encountered
Severity: Warning
Message: fsockopen(): unable to connect to ssl://smtp.googlemail.com:465 (A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. )
Filename: libraries/Email.php
Line Number: 1689
I have google about three hours and still not found the solution. I have already enabled 'openssl
' in Apache. I would like to describe coding for my Email Controller Class.
//Code of Email Controller 'Index' function
$this->load->library('email');
$this->email->set_newline("\r\n");
$config['charset'] = 'utf-8';
$config['wordwrap'] = TRUE;
$config['mailtype'] = 'html';
$config['protocol'] = 'smtp';
$config['smtp_port'] = 465;
$config['smtp_host'] = 'ssl://smtp.googlemail.com';
$config['smtp_user'] = "something@gmail.com";
$config['smtp_pass'] = "xxx";
$this->email->initialize($config);
$this->email->from('something@gmail.com', 'NayLinAung');
$this->email->to('something@gmail.com');
$this->email->subject('This is an email test');
$this->email->message("It is working, Great! You will be successful.");
if ($this->email->send())
{
echo "Email was successfully sent.";
}
else {
show_error($this->email->print_debugger());
}
When I change 'smtp' to 'mail', errors are not occurred but the email was not actually sent. In addition, I shutdown my Windows firewall.
Please, suggest any solutions for this error.