Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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://smtp.googlemail.com:465 (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.googlemail.com',
                   'smtp_port' => 465,
                   'smtp_timeout' => 30,
                   'smtp_user' => 'myemail',
                   'smtp_pass' => 'mypassword'           
                     );
                    $this->load->library('email',$config);
                   $this->email->set_newline("\r\n");                      
                   $this->email->from('myemail', 'hello');

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

                        if($this->email->send())
                   {



                       return TRUE;
                    }

                   else 
                   {
                     echo "error";
                     show_error($this->email->print_debugger());  
                      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 professional 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
add comment

1 Answer 1

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
add comment

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