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
| // email fields: to, from, subject, and so on
$to = "TEST@lit.gmail.com";
$subject ="My subject";
$from = $_POST['netID']."@gmail.com <".$_POST['netID']."@gmail.com>";
$message = '<div style="text-align:center";><img id="logo_TEST" width="102px" height="120px" src="http://TEST.gmail.com/dokuwiki/lib/exe/fetch.php?cache=&media=TEST-logo.png" /></div>';
$message.= "<p><b>".$_POST['matricule'] . " " . $_POST['prenom'] . " " . $_POST['nom'] . " (" . $_POST['netID']."</b>) a laissé ce message </p>";
$message.= "\n\n";
if(isset($_SESSION['$path']))
{
$fichier_joint = explode('\\',$_POST["piece_jointe"]);
$message.= "<p>Pièce jointe : <a href='TEST.gmail.com/help/upload/".$_POST['piece_jointe']."'>TEST.gmail.com/help/upload/".$fichier_joint[sizeof($fichier_joint)-1]."</a></p>";
}
$headers = "From: $from";
if(isset($_SESSION['$path']))
{
$path = $_SESSION['$path'];
}
// boundary
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
// headers for attachment
$headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\"";
// multipart boundary
$message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type: text/html; charset=\"UTF-8\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $message . "\n\n";
$message .= "--{$mime_boundary}\n";
if(isset($_SESSION['$path']))
{
// preparing attachments
$file = fopen($path,"rb");
$data = fread($file,filesize($path));
fclose($file);
$data = chunk_split(base64_encode($data));
$message .= "Content-Type: {\"application/octet-stream\"};\n" . " name=\"$path\"\n" . "Content-Disposition: attachment;\n" . " filename=\"$path\"\n" . "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n";
$message .= "--{$mime_boundary}\n";
}
// send
$ok = @mail($to, $_POST['campus']." ".$_POST['faculte']." ".$_POST['local']." ".$_POST['type_probleme'], $message, $headers);
unset($_SESSION['$path']);
print_r($_SESSION);
if ($ok)
{
echo "<p>mail sent to $to!</p>";
}
else
{
echo "<p>mail could not be sent!</p>";
} |