Link to home
Start Free TrialLog in
Avatar of cbielich
cbielichFlag for United States of America

asked on

Warning: fsockopen() expects parameter 2 to be long, string given

Im lost, I switched to google apps so I dont have my internal smtp server anymore. Thats fine Ill just use google's. Well for the life of me I cant get it to work. Im sure Im missing something small. Please someone help me. Here is the error
-----
Warning: fsockopen() expects parameter 2 to be long, string given in C:\Program Files\Apache Group\Apache2\htdocs\custom\clockin\includes\phpmailer\class.smtp.php on line 105
Message was not sent
Mailer Error: SMTP Error: Could not connect to SMTP host.
-----

Here is the code at line 105 of class.smtp.php
$this->smtp_conn = fsockopen($host,    # the host of the server
   $port,    # the port to use
   $errno,   # error number if any
   $errstr,  # error message if any
   $tval);   # give up after ? secs  <----line 105----<

Open in new window

Avatar of Beverley Portlock
Beverley Portlock
Flag of United Kingdom of Great Britain and Northern Ireland image

What value is in $port? If you run this

var_dump($port);

$this->smtp_conn = fsockopen($host,    # the host of the server
   $port,    # the port to use
   $errno,   # error number if any
   $errstr,  # error message if any
   $tval);   # give up after ? secs  <----line 105----<

What does it say? You could try casting $port

$this->smtp_conn = fsockopen($host,    # the host of the server
   intval($port),    # the port to use
   $errno,   # error number if any
   $errstr,  # error message if any
   $tval);   # give up after ? secs  <----line 105----<
Avatar of cbielich

ASKER

Here is my code I am passing. I should have specified I am using PhPMailer


<?php
require("class.phpmailer.php");
$mailer = new PHPMailer();
$mailer->IsSMTP();
$mailer->Host = 'ssl://smtp.google.com';
$mailer->Port = '465';
$mailer->SMTPAuth = true;
$mailer->Username = 'username@domain.com';  // Change this to your gmail adress
$mailer->Password = 'password';  // Change this to your gmail password
$mailer->From = 'username@domain.com';  // This HAVE TO be your gmail adress
$mailer->FromName = 'fake'; // This is the from name in the email, you can put anything you like here
$mailer->Body = 'This is the main body of the email';
$mailer->Subject = 'This is the subject of the email';
$mailer->AddAddress('username@domain.com');  // This is where you put the email adress of the person you want to mail
if(!$mailer->Send())
{
   echo "Message was not sent<br/ >";
   echo "Mailer Error: " . $mailer->ErrorInfo;
}
else
{
   echo "Message has been sent";
}
?>

Open in new window

Ah i think I found it, I added $host and $port manually and I get "Warning: fsockopen(): no SSL support in this build in C:\Program Files\Apache Group\Apache2\htdocs\custom\clockin\includes\phpmailer\class.smtp.php on line 106"

How do I enable SSL support for fsockopen or at least confirm it supports it or not?
Ugh is it true ssl will not work with php4?
To confirm whether SSL is present do

<?php
phpinfo();

and press CTRL-F to scan for SSL. I'm not sure how to set it up on Windows, on Linux it's a snap....

This may helpful. Scroll down to section 2   http://tud.at/programm/apache-ssl-win32-howto.php3

"...is it true ssl will not work with php4?"

I don't know, I'm a Linux type, not a Windows type. If you think that you are going to have loads of problems, why not just bite the bullet and install XAMPP which would give you PHP5, OpenSSL, etc. etc.

Look at the feature list here http://www.apachefriends.org/en/xampp-windows.html

You would need to dump your databases to SQL, uninstall stuff, run the XAMPP install and then reload the databases back into MySQL.
Here is a section from my phpinfo, shows ssl mod loaded


apache2handler

Apache Version      Apache/2.0.54 (Win32) mod_ssl/2.0.54 OpenSSL/0.9.8 PHP/4.4.0
Apache API Version      20020903
Server Administrator      john@schooldynamics.net
Hostname:Port      localhost:8080
Max Requests      Per Child: 0 - Keep Alive: on - Max Per Connection: 100
Timeouts      Connection: 300 - Keep-Alive: 0
Virtual Server      No
Server Root      C:/Program Files/Apache Group/Apache2
Loaded Modules      core mod_win32 mpm_winnt http_core mod_so mod_access mod_actions mod_alias mod_asis mod_auth mod_autoindex mod_cgi mod_dir mod_env mod_imap mod_include mod_isapi mod_log_config mod_mime mod_negotiation mod_setenvif mod_userdir mod_ssl sapi_apache2
Its not really my server, I mean it is but its a thrid part software that uses php4. I dont want to just go in and change settings :) It is a windows box but I am a linux guy too. Think Ill just make a box for this lol
Maybe cancel this question and ask a more specific question about SSL and PHP4 under Windows in the "PHP & Windows" section?
ASKER CERTIFIED SOLUTION
Avatar of cbielich
cbielich
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
IN that case I'm not sure how you would elect to close this question. I'll leave that decision with you, but I'll go along with whatever you decide.

Ill just accept my answer to you :)