 | | Offres d'emplois |  | Intégrateur web Société spécialisée dans la Vente par Internet recrute :
Intégrateur Web en CDI
Débutants Passionnés.
Connaissances requises :
- maîtrise d... | |
 | | Avez vous lu ? |  | | |
|
 Envoyez un mail avec une pièce jointe | |  |

<?
if ($action == "4_2") {
$liste = $destinataire;
$adresses_mails = file($liste);
for ($i=0; $i< count($adresses_mails); $i++) $adresses_mails[$i] = trim($adresses_mails[$i]);
$destinataires = implode(",",$adresses_mails);
$uploaddir = './fichiers/';
$upload_file = $uploaddir . $_FILES['piecejointe']['name'];
$objet = $_POST["objet"];
$message = htmlspecialchars($_POST["corps_mail"], ENT_QUOTES);
if (move_uploaded_file($_FILES['piecejointe']['tmp_name'], $upload_file)) {
$ext = explode(".", basename($_FILES['piecejointe']['name']));
switch($ext[1]) {
default:
$attach_type = "application/octet-stream";
break;
case "gz":
$attach_type = "application/x-gzip";
break;
case "tgz":
$attach_type = "application/x-gzip";
break;
case "zip":
$attach_type = "application/zip";
break;
case "pdf":
$attach_type = "application/pdf";
break;
case "png":
$attach_type = "image/png";
break;
case "gif":
$attach_type = "image/gif";
break;
case "jpg":
case"jpeg":
$attach_type = "image/jpeg";
break;
case "txt":
$attach_type = "text/plain";
break;
case "htm":
$attach_type = "text/html";
break;
case "html":
$attach_type = "text/html";
break;
}
$attach_name = $_FILES["piecejointe"]["name"];
}
if (file_exists($upload_file)) {
$file = fopen($upload_file, "r");
$contents = fread($file, filesize($upload_file));
$encoded_attach = chunk_split(base64_encode($contents));
fclose($file);
}
$mailheaders = "From: stephane@fd-up.com\n";
$mailheaders .= "Reply-To: stephane@fd-up.com\n";
$mailheaders .= "To: $destinataires\n";
$mailheaders .= "MIME-version: 1.0\n";
$mailheaders .= "Content-type: multipart/mixed; ";
$mailheaders .= "boundary=\"Message-Boundary\"\n";
$mailheaders .= "Content-transfer-encoding: 7BIT\n";
$mailheaders .= "X-attachments: $attach_name\n";
$body_top = "--Message-Boundary\n";
$body_top .= "Content-type: text/plain;
charset=ISO-8859-1\n";
$body_top .= "Content-transfer-encoding: 7BIT\n";
$msg_body = $body_top . $message;
$msg_body .= "\n\n--Message-Boundary\n";
$msg_body .= "Content-type: $attach_type; name=\"$attach_name\"\n";
$msg_body .= "Content-Length: " . filesize($upload_file) . "\n";
$msg_body .= "Content-transfer-Encoding: BASE64\n";
$msg_body .= "Content-disposition: attachment; filename=\"$attach_name\"\n\n";
$msg_body .= "$encoded_attach\n";
$msg_body .= "--Message-Boundary--\n";
if (mail($destinataires, $objet,
$msg_body, $mailheaders)) {
echo "envoi réussi du
mail : ".$objet. " à $destinataires.";
}
else {
echo "Echec de l'envoi du
mail".$objet.".";
}
}
?>
|
|
|
 |
|