Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to send email when a user registers but I get so many errors like

A PHP Error was encountered

Severity: Warning

Message: fsockopen() [function.fsockopen]: unable to connect to ssl:// (Connection timed out)

Filename: libraries/Email.php

Line Number: 1689

A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at /home/vtustude/public_html/system/core/Exceptions.php:185)

Filename: core/Common.php

Line Number: 438

Every thing works well in my local system I don't know whats the problem when its online

Here is my code

function sending_email() { $email = 'myemail';

                    $config = array(
                   'protocol' => 'smtp',
                   'smtp_host' => 'ssl://',
                   'smtp_port' => 465,
                   'smtp_timeout' => 30,
                   'smtp_user' => 'myemail',
                   'smtp_pass' => 'mypassword'           
                   $this->email->from('myemail', 'hello');

                   $this->email->subject('Hello, ');
                       $this->email->message("Dear user ");


                       return TRUE;

                     echo "error";
                      return FALSE;


Please help me Thanks

share|improve this question

closed as off topic by Iain Aug 20 '12 at 8:37

Questions on Server Fault are expected to relate to server, networking, or related infrastructure administration within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

Welcome to Server Fault! Your question seems off topic for this site as it appears to relate to programming. It may be on topic for Stackoverflow but please search their site for similar questions before asking. – Iain Aug 20 '12 at 8:36

most probably your hosting provider filters out traffic and prevents your code from connecting to port 465/tcp of google's mail servers.

try contacting the service provider and either ask to open up the firewall [unlikely] or use their mail relay.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.