i wish to use gmail smtp to send user information to the registered email.
The code that i am using is working fine in my localhost, but when i changed into shared hosting it come out with the below error.
A PHP Error was encountered
Severity: Warning
Message: fsockopen() [function.fsockopen]: unable to connect to ssl://smtp.googlemail.com:465 (Connection timed out)
Filename: libraries/Email.php
Line Number: 1652
A PHP Error was encountered
Severity: Warning
Message: fwrite(): supplied argument is not a valid stream resource
Filename: libraries/Email.php
Line Number: 1795
.... (more error msg here)
An Error Was Encountered
The following SMTP error was encountered: 110 Connection timed out
Unable to send data: AUTH LOGIN
Failed to send AUTH LOGIN command. Error:
Unable to send data: MAIL FROM:
from:
The following SMTP error was encountered:
Unable to send data: RCPT TO:
to:
The following SMTP error was encountered:
Unable to send data: DATA
.... (more error msg here)
Here's my email config
$pass = $this->generatePassword('6'); $config = Array( 'protocol' => 'smtp', 'smtp_host' => 'ssl://smtp.googlemail.com', 'smtp_port' => 465, 'smtp_timeout'=>'30', 'smtp_user' => 'username@gmail.com', 'smtp_pass' => 'mypassword', 'mailtype' => 'html', 'charset' => 'iso-8859-1' ); $this->load->library('email', $config); $this->email->set_newline("\r\n"); $this->email->from('admin@lalala.com','Title'); $this->email->to($this->input->post('email')); $this->email->subject('Subject here'); $this->email->message('Your login username is '.$this->input->post('username').'<br/>'.'Password is '.$pass); if (!$this->email->send()){ show_error($this->email->print_debugger()); }else{ echo 'YEAH!!!';}
i try to check my share hosting openssl whether is enabled or not. and i found this
openssl
OpenSSL support enabled
OpenSSL Version OpenSSL 0.9.8e-fips-rhel5 01 Jul 2008
If openssl is enabled. still what will be the mistake in my code?
I start to be frustrated to use my localhost to develop and when its uploaded to share hosting, it came out wit lots of error.
Any help would be appreciate!! thx in advanced
Looks like ur ssl port in shared hosting is close, use this code to check if it is open.
there is update for test script in newer php version: