rendered paste bodyfunction mail_socket($to, $subject, $msg, $from, $reply)
{
echo "Envoi d'un mail à $to<br>";
$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)<br/>\n";
else
{
$res1=fgets($connection, 256);
if(substr($res1, 0, 3) != "220") echo "error : $res1<br/>";
fputs($connection, "HELO localhost\n");
$res2=fgets($connection, 256);
if(substr($res2, 0, 3) != "250") echo "error : $res2<br/>";
fputs($connection, "MAIL FROM: $from\n");
$res3=fgets($connection, 256);
if(substr($res3, 0, 3) != "250") echo "error : $res3<br/>";
fputs($connection, "RCPT TO: $to\n");
$res4=fgets($connection, 256);
if(substr($res4, 0, 3) != "250") echo "error : $res4<br/>";
fputs($connection, "DATA\n");
$res5=fgets($connection, 256);
if(substr($res5, 0, 3) != "354") echo "error : $res5<br/>";
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<br/>";
fputs($connection, "QUIT\n");
$res7=fgets($connection, 256);
if(substr($res7, 0, 3) != "221") echo "error : $res7<br/>";
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<hr>";
return $res1."<br/>".$res2."<br/>".$res3."<br/>".
$res4."<br/>".$res5."<br/>".$res6."<br/>".$res7;
}