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
|
<?php
if (isset($_POST['envoyer']) == "Demander"){
EnvoiMail();
}
// Fonction Mail
function EnvoiMail(){
$boundary='azertyuiop';
//En-têtes du mail
$headers="From: test@test.fr\r\n
MIME-Version: 1.0\r\n
Content-Type: multipart/mixed; boundary=\"$boundary\"\r\n\n";
//Corps du mail en commençant par le message principal
$body="--". $boundary ."\n
Content-Type: text/plain; charset=ISO-8859-1\r\n\n
Message principal du mail.\n\n";
$fichier=file_get_contents('./test.doc');
$fichier=chunk_split( base64_encode($fichier) );
//Ecriture de la pièce jointe
$body = $body . "--" .$boundary. "\n
Content-Type: application/msword; name=\"nom_fichier\"\r\n
Content-Transfer-Encoding: base64\r\n
Content-Disposition: attachment; filename=\"nom_fichier\"\r\n\n
$fichier";
//Fermeture de la frontière
$body = $body . "--" . $boundary ."--";
//Envoi du mail
mail("test@test.fr", "test fj", $body, $headers);
}
?> |
Partager