Ok, I'm writing a program that loads a list of relay servers from a text file into an array, then I'm attempting to verify that each one works by analyzing the responses to my fputs commands to the smtp recipient relay server.
Anyway, the problem I'm having is that my program stalls and eventually lets the connection timeout before continuing. The part of the code where the program times out is below.
For our purposes, I have edited my code to make it more legible to people who can't see my entire program and all of the functions...
For the program to get this far, assume the following:
$mysocket is a successfully connected socket.
The HELO command was successfull and there is no command between HELO and the MAIL FROM fputs.
print_out() outputs to the screen.
get_command() returns an array, first value is the response text matching up with a smtp response code, second value is true or false weather or not the command worked according to the response code.
$SEED_EMAIL is a valid email address.
the socket timeout is set to 5 seconds, although this is not necessary.
fputs($mysocket,'MAIL FROM:<'.$SEED_EMAIL.'>\r\n');
$feed = fgets($mysocket, 3);
if($feed)
{
print_out('Response: '.$feed.'\n');
$response = get_command($feed);
if($response[1] === true)
print_out('Success: '.$response[0].'.\n');
else
{
print_out('Error: '.$response[0].'.\n');
//log to failed_relays
}
//dump the rest of the message
$feed = fgets($mysocket, 1024);
}
else
print_out('Error: No response from MAIL FROM Request.\n');