Salut à tous !
Alors voila ce qui se passe :
Je rempli un formulaire html.
A la validation, je génère un fichier PDF à partir de ce qui a été entré, je génère aussi un texte sommaire.
J'envoie le tout par mail, avec le pdf en pièce jointe.
Voici le code :
[cpp]<?php
$boundary="voilalafrontierepourseparertexteetpiecejointe";
$nom=$_POST['nomMail'];
$mail=$_POST['mailMail'];
$objet=$_POST['objetMail'];
$message=$_POST['messageMail'];
/////voici la version Mine
$headers = "MIME-Version: 1.0\r\n";
//////ici on détermine le mail en format text
$headers .= "Content-type: multipart/mixed; boundary=\"$boundary\"\r\n\n";
////ici on détermine l'expediteur et l'adresse de réponse
$headers .= "From: $nom <supertoms@neuf.fr>\r\nReply-to : $nom <supertoms@neuf.fr>\nX-Mailer:PHP";
$subject="$objet";
$destinataire="toms@free.fr";
$body="--".$boundary."\n
Content-Type: text/plain; charset=ISO-8859-1\r\n\n
".$message."\n\n";
$fichier=file_get_contents('..\dossier.pdf');
$fichier=chunk_split( base64_encode($fichier));
$body = $body . "--" . $boundary . "\n
Content-Type: application/pdf; name=\"dossier.pdf\"\r\n
Content-Transfer-Encoding: base64\r\n
Content-Disposition: attachment; filename=\"nom_fichier\"\r\n\n
$fichier";
$body = $body . "--" . $boundary ."--";
if (mail($destinataire,$subject,$body,$headers)) {
echo "Votre mail a été envoyé";
} else {
echo "Une erreur s'est produite";
}
?>[/cpp]
Voila, pour info la génération du fichier dossier.pdf fonctionne bien.
Mon problème est le suivant : je reçoi le mail, mais ca ressemble à cette chose horrible :
<strong>DEMANDEUR :</strong><br />monsieur ARFOUILLE Thomas<br /><br />Adresse :<br />sdgs<br />69300 ezg<br /><br />Tél. fixe : 0412345678<br /> Tél. mobil : 0612121212 <br /> Mail : toms@free.fr <br /><br /><strong>ELEVE :</strong><br />Nom : ezgfezdgf <br />Prenom : ezgf <br />Date de naissance : 18/02/2003 <br />Etablissement : ezfve <br />Classe : ezgfez <br /> <br /><strong>MESSAGE OPTIONNEL :</strong><br />ezgfez--voilalafrontierepourseparertexteetpiecejointe
Content-Type: application/pdf; name="dossier.pdf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="nom_fichier"
JVBERi0xLjMKMyAwIG9iago8PC9UeXBlIC9QYWdlCi9QYXJlbnQgMSAwIFIKL1Jlc291cmNlcyAy
IDAgUgovQ29udGVudHMgNCAwIFI+PgplbmRvYmoKNCAwIG9iago8PC9GaWx0ZXIgL0ZsYXRlRGVj
b2RlIC9MZW5ndGggNDg2Pj4Kc3RyZWFtCnichVPLctNAELznK+YIh4x39r2cSGJRFYqEIgjui7Ry
...et bien d'autres caractères pendant trèèèès longtemps !
Voila, merci d'avance!
Configuration: Windows XP
Firefox 2.0.0.3