Solved

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

Posted on 2010-09-21
12
2,402 Views
Last Modified: 2013-11-30
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
Comment
Question by:cbielich
  • 7
  • 5
12 Comments
 
LVL 34

Expert Comment

by:Beverley Portlock
ID: 33730072
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
 
LVL 1

Author Comment

by:cbielich
ID: 33730165
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
 
LVL 1

Author Comment

by:cbielich
ID: 33730178
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
 
LVL 1

Author Comment

by:cbielich
ID: 33730185
Ugh is it true ssl will not work with php4?
0
 
LVL 34

Expert Comment

by:Beverley Portlock
ID: 33730192
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
 
LVL 34

Expert Comment

by:Beverley Portlock
ID: 33730217
"...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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 1

Author Comment

by:cbielich
ID: 33730219
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
 
LVL 1

Author Comment

by:cbielich
ID: 33730223
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
 
LVL 34

Expert Comment

by:Beverley Portlock
ID: 33730356
Maybe cancel this question and ask a more specific question about SSL and PHP4 under Windows in the "PHP & Windows" section?
0
 
LVL 1

Accepted Solution

by:
cbielich earned 0 total points
ID: 33730362
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
 
LVL 34

Expert Comment

by:Beverley Portlock
ID: 33730386
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
 
LVL 1

Author Comment

by:cbielich
ID: 33731532
Ill just accept my answer to you :)
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

There was an incident about the POP3 issue for the double read receipts and delivery receipts in Exchange 2013.  There was huge research been done and found solution for the duplicate mails. Especially when the user gets  duplicate mails.
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to dynamically set the form action using jQuery.

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now