Bonjour !
Jai un gros souci en php .
J'essai denvoyer un mail avec une piece jointe mais ca ne marche pas:
je recois un mail dans yahoo mais il ny a pas de piece jointe !!
voici mon formulaire html :
<form action="envoiimage.php" method="post" enctype="multipart/form-data" name="form1">
<p><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Choisissez
l'image a envoyer (qui devra s'appeller logo.gif):</strong></font>
<input name="logo" type="file">
<p><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Entrez
votre mail :</strong></font>
<input name="mailtoto" type="text" id="mailtoto" size="60">
<p align="center">
<input type="submit" name="Submit" value="Envoyer">
et le fichier envoiimage.php me renvoi un mail sans piece attachée :
<?php
$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: text/plain; charset=\"iso-8859-1\"\r\n";
$msg .= "Content-Transfer-Encoding:8bit\r\n";
$msg .= "\r\n";
$msg .= "Ceci est un mail avec un fichier joint\r\n";
$msg .= "\r\n";
$file = $_POST['logo'];
$fp = fopen($file, 'rb');
$attachment = fread($fp, filesize($file));
fclose($fp);
$attachment = chunk_split(base64_encode($attachment));
$msg .= "--$boundary\r\n";
$msg .= "Content-Typ e: image/gif; name=\"$file\"\r\n";
$msg .= "Content-Transfer-Encoding: base64\r\n";
$msg .= "Content-Disposition: inline; filename=\"$file\"\r\n";
$msg .= $attachment . "\r\n";
$msg .= "\r\n\r\n";
$msg .= "--$boundary--\r\n";
$mailtoto = $_POST['mailtoto'];
$destinataire = "davidcz26@yahoo.fr";
$expediteur = $mailtoto;
$reponse = $expediteur;
mail($destinataire, "test avec fichier attaché", $msg,
"Reply-to: $reponse\r\nFrom: $expediteur\r\n".$header);
?>
Je ne vois pas ou est mon erreur.
Pouvez-vous m'eclairer ?
Merci a vous
Partager