By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,738 Members | 1,769 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,738 IT Pros & Developers. It's quick & easy.

how to handle server responses?

P: n/a
Hi,

i try to write a small php email client, the problem
with the script is that i can't handle the server response,
the script ignores if the server lags and sent the requests

the script looks like this:

# open Socket.
$fp = fsockopen($server, $port);
if($fp) {
$result = fgets($fp, 1024);

# HELO
fputs($fp, "HELO ".randomip()."\r\n");
$result = fgets($fp, 1024);
if ($result+0 != 220 || $result+0 != 250)
#die("HELO Statuscode falsch: $result");

# MAIL FROM
fputs($fp, "MAIL FROM: <".$firstname.$lastname."@".$domain.">\r\n");
$result = fgets($fp, 1024);
if ($result+0 != 250)
#die("MAIL FROM Statuscode falsch: $result");
the other problem is that the status codes (220/250) validation dont work
i have to use sleep(); timeouts and uncomment the die; parts to run the script

is there a better way to handle this?

regards
Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
checksumde wrote:
Hi,

i try to write a small php email client, the problem
with the script is that i can't handle the server response,
the script ignores if the server lags and sent the requests

the script looks like this:

# open Socket.
$fp = fsockopen($server, $port);
if($fp) {
$result = fgets($fp, 1024);

# HELO
fputs($fp, "HELO ".randomip()."\r\n");
$result = fgets($fp, 1024);
if ($result+0 != 220 || $result+0 != 250)
#die("HELO Statuscode falsch: $result");

# MAIL FROM
fputs($fp, "MAIL FROM: <".$firstname.$lastname."@".$domain.">\r\n");
$result = fgets($fp, 1024);
if ($result+0 != 250)
#die("MAIL FROM Statuscode falsch: $result");
the other problem is that the status codes (220/250) validation dont work
i have to use sleep(); timeouts and uncomment the die; parts to run the script

is there a better way to handle this?

regards


Are you sure your script is not timeing out? By default, scripts will
terminate inside 30seconds if they have not 'ended' normally. You can
work around this either by using set_time_limit() or changing
max_execution_time directive in your config file.

randelld
Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.