how to handle server responses?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • checksumde

    how to handle server responses?

    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($serv er, $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."@".$d omain.">\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
  • Reply Via Newsgroup

    #2
    Re: how to handle server responses?

    checksumde wrote:
    [color=blue]
    > 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($serv er, $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."@".$d omain.">\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[/color]

    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_t ime directive in your config file.

    randelld

    Comment

    Working...