function mail_socket($to, $subject, $msg, $from, $reply) { echo "Envoi d'un mail à $to
"; $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/plain; charset=iso-8859-1\r\n"; $headers .= "Reply-To: $reply\r\n"; $headers .= "X-Mailer: PHP SCRIPT"; $connection = fsockopen ("localhost", 25, $errno, $errstr, 1); if (!$connection) echo "$errstr ($errno)
\n"; else { $res1=fgets($connection, 256); if(substr($res1, 0, 3) != "220") echo "error : $res1
"; fputs($connection, "HELO localhost\n"); $res2=fgets($connection, 256); if(substr($res2, 0, 3) != "250") echo "error : $res2
"; fputs($connection, "MAIL FROM: $from\n"); $res3=fgets($connection, 256); if(substr($res3, 0, 3) != "250") echo "error : $res3
"; fputs($connection, "RCPT TO: $to\n"); $res4=fgets($connection, 256); if(substr($res4, 0, 3) != "250") echo "error : $res4
"; fputs($connection, "DATA\n"); $res5=fgets($connection, 256); if(substr($res5, 0, 3) != "354") echo "error : $res5
"; fputs($connection, "TO: $to\nFrom: $reply\nSubject: $subject\n$headers\n\n$msg\n.\n"); $res6=fgets($connection, 256); if(substr($res6, 0, 3) != "250") echo "error : $res6
"; fputs($connection, "QUIT\n"); $res7=fgets($connection, 256); if(substr($res7, 0, 3) != "221") echo "error : $res7
"; fclose ($connection); } if(substr($res1, 0, 3) == "220" && substr($res2, 0, 3) == "250" && substr($res3, 0, 3) == "250" && substr($res4, 0, 3) == "250" && substr($res5, 0, 3) == "354" && substr($res6, 0, 3) == "250" && substr($res7, 0, 3) == "221") echo "mesage envoyé correctement
"; return $res1."
".$res2."
".$res3."
". $res4."
".$res5."
".$res6."
".$res7; }