server_name can use PHP's own dns resolution function,
The following is the core demonstration, winNT, mail server is Imail,php3.0.6
You need to modify php3.ini to open the imap module, and compile php on Linux --with- IMAP
function send_email ( $to,$from,$subject,$message ){
global $SERVER_NAME;
$fp = fsockopen ( $SERVER_NAME, 25 );
if ( $fp ){
echo "connected";
set_socket_blocking( $fp, false );
$output=fgets($fp,2500);
echo $output;
if (! ereg ( "^220", $output ) ) {
exit();
} else {
echo " talking ";
//set_socket_blocking ( $fp, true );
fputs ( $fp, "HELO $from_domain
" );
$output = fgets ( $fp, 2000 );
echo $output;
fputs ( $fp, "MAIL FROM:
" );
$output = fgets ( $fp, 2000 );
echo $output;
fputs ( $fp, "RCPT TO:
" );
$output = fgets ( $fp, 2000 );
echo $output;
fputs($fp,"DATA
");
fputs($fp,"To: $to
");