1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
| :
<html>
<body> <center>
<?
$name_file = $_FILES['monfichier']['name'];
$source=$_FILES['monfichier']['tmp_name'];
move_uploaded_file($source, "./".$name_file);
$extension=get_extension($name_file);
$type="text/plain";
if($type=="doc")
{
$type="text/vnd.ms-word";
}
else if($type=="xls")
{
$type="text/vnd.ms-excel";
}
$type2="image/png";
if($extension=="gif")
{
$type2="image/gif";
}
else if($extension=="bmp")
{
$type2="image/bmp";
}
function get_extension($filename)
{
$parts = explode('.',$filename);
$last = count($parts) - 1;
$ext = $parts[$last];
return $ext;
}
//----------------------------------
// Construction de l'entête
//----------------------------------
if($_POST['to']!="")
{
$boundary = "-----=".md5(uniqid(rand()));
$header = "MIME-Version: 1.0\r\n";
$header .= "Content-Type: multipart/mixed; boundary=\"$boundary\"\r\n";
$header .= "\r\n";
$msg = "Je vous informe que ceci est un message au format MIME 1.0 multipart/mixed.\r\n";
$msg .= "--$boundary\r\n";
$msg .= "Content-Type: $type; charset=\"iso-8859-1\"\r\n";
$msg .= "Content-Transfer-Encoding:8bit\r\n";
$msg .= "\r\n";
$msg .= $_POST['message'];
$msg .= "\r\n";
if($name_file!="")
{
$file = $name_file;
$fp = fopen($file, "rb");
$attachment = fread($fp, filesize($file));
fclose($fp);
$attachment = chunk_split(base64_encode($attachment));
$msg .= "--$boundary\r\n";
$msg .= "Content-Type: $type2; name=\"$file\"\r\n";
$msg .= "Content-Transfer-Encoding: base64\r\n";
$msg .= "Content-Disposition: inline; filename=\"$file\"\r\n";
$msg .= "\r\n";
$msg .= $attachment . "\r\n";
$msg .= "\r\n\r\n";
$msg .= "--$boundary--\r\n";
}
$destinataire = $_POST['to'];
$expediteur = $_POST['from'];
$reponse = $expediteur;
echo "Mail envoyé à $destinataire";
mail($destinataire, $_POST['message'], $msg,
"Reply-to: $reponse\r\nFrom: $expediteur\r\n".$header);
}
if($name_file!="")
{
unlink($name_file);
}
print("<br>\n");
print("<br><A href=./mail3.php target=\"principal\"><font size=2>Envoyer un autre mail</font></A>");
?>
</center>
</body>
</html> |
Partager