Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3063
  • Last Modified:

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

0
cbielich
Asked:
cbielich
  • 7
  • 5
1 Solution
 
Beverley PortlockCommented:
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----<
0
 
cbielichAuthor Commented:
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

0
 
cbielichAuthor Commented:
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?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
cbielichAuthor Commented:
Ugh is it true ssl will not work with php4?
0
 
Beverley PortlockCommented:
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

0
 
Beverley PortlockCommented:
"...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.
0
 
cbielichAuthor Commented:
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
0
 
cbielichAuthor Commented:
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
0
 
Beverley PortlockCommented:
Maybe cancel this question and ask a more specific question about SSL and PHP4 under Windows in the "PHP & Windows" section?
0
 
cbielichAuthor Commented:
I think it might be useful in understanding that fsockopen() with ssl does not work with php4. Only php5 which is what I would mark as the answer
0
 
Beverley PortlockCommented:
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.

0
 
cbielichAuthor Commented:
Ill just accept my answer to you :)
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 7
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now