- // definition du serveur de mail
- define("SERVEURMAIL","197.234.22.485");
- ou
- define("SERVEURMAIL","mailhost.monDomaine.fr");
-
-
- //fonction email
-
- function email($from, $to, $subject, $msg,$content="text/plain"){
- $headers = "MIME-Version: 1.0\r\n";
- $headers .= "Content-type: ".$content;
- $headers .= ";charset=iso-8859-1\r\n";
- $headers .= "Reply-To: $from\r\n";
- $headers .= "X-Mailer: PHP SCRIPT";
-
- if ($from!=null && $to!=null && $subject!=null && $msg!=null)
- //&& checkmail($from)&&checkmail($to)
- {
- $connection = fsockopen (SERVEURMAIL,25, &$errno,
- &$errstr, 1);
- if (!$connection) {
- return false;
- } else {
- $res1=fgets($connection, 256);
- if(substr($res1, 0, 3) != "220") return false;
-
- fputs($connection, "HELO localhost\n");
- $res2=fgets($connection, 256);
- if(substr($res2, 0, 3) != "250") return false;
-
- fputs($connection, "MAIL FROM: $from\n");
- $res3=fgets($connection, 256);
- if(substr($res3, 0, 3) != "250") return false;
-
- fputs($connection, "RCPT TO: $to\n");
- $res4=fgets($connection, 256);
- if(substr($res4, 0, 3) != "250") return false;
-
- fputs($connection, "DATA\n");
- $res5=fgets($connection, 256);
- if(substr($res5, 0, 3) != "354") return false;
-
- fputs($connection, "TO:$to\nFrom:$from\nSubject:$subject\n$headers\n\n$msg\n.\n");
- $res6=fgets($connection, 256);
- if(substr($res6, 0, 3) != "250") return false;
-
- fputs($connection, "QUIT\n");
- $res7=fgets($connection, 256);
- if(substr($res7, 0, 3) != "221") return false;
-
- 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") return true;
- }else{
- return false;
- }
- }
// definition du serveur de mail
define("SERVEURMAIL","197.234.22.485");
ou
define("SERVEURMAIL","mailhost.monDomaine.fr");
//fonction email
function email($from, $to, $subject, $msg,$content="text/plain"){
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: ".$content;
$headers .= ";charset=iso-8859-1\r\n";
$headers .= "Reply-To: $from\r\n";
$headers .= "X-Mailer: PHP SCRIPT";
if ($from!=null && $to!=null && $subject!=null && $msg!=null)
//&& checkmail($from)&&checkmail($to)
{
$connection = fsockopen (SERVEURMAIL,25, &$errno,
&$errstr, 1);
if (!$connection) {
return false;
} else {
$res1=fgets($connection, 256);
if(substr($res1, 0, 3) != "220") return false;
fputs($connection, "HELO localhost\n");
$res2=fgets($connection, 256);
if(substr($res2, 0, 3) != "250") return false;
fputs($connection, "MAIL FROM: $from\n");
$res3=fgets($connection, 256);
if(substr($res3, 0, 3) != "250") return false;
fputs($connection, "RCPT TO: $to\n");
$res4=fgets($connection, 256);
if(substr($res4, 0, 3) != "250") return false;
fputs($connection, "DATA\n");
$res5=fgets($connection, 256);
if(substr($res5, 0, 3) != "354") return false;
fputs($connection, "TO:$to\nFrom:$from\nSubject:$subject\n$headers\n\n$msg\n.\n");
$res6=fgets($connection, 256);
if(substr($res6, 0, 3) != "250") return false;
fputs($connection, "QUIT\n");
$res7=fgets($connection, 256);
if(substr($res7, 0, 3) != "221") return false;
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") return true;
}else{
return false;
}
}