cs_sidalilo
Messages postés108Date d'inscriptionmardi 28 février 2006StatutMembreDernière intervention 9 juillet 2013
-
7 nov. 2012 à 14:28
sylvain64520
Messages postés130Date d'inscriptionlundi 11 janvier 2010StatutMembreDernière intervention 7 juin 2013
-
13 nov. 2012 à 16:08
bonjour
je veux envoyer un mail avec piece jointe vers ma boite mail yahoo mais le fichier joint qui a été recu dans ma boite email est vide voila ma fonction d'envoi mail:
$boundary='glandouillepas';
//En-têtes du mail
$headers="MIME-Version: 1.0\r\n";
$headers.="Content-Type: multipart/mixed; boundary="$boundary"\r\n";
$headers.="From: ali.driss@htshightechsystems212.com\r\n";
//Corps du mail en commençant par le message principal
$body="--". $boundary ."\n";
$body.="Content-Type: text/plain; charset=ISO-8859-1\r\n";
$body.="SALAM.\n\n";
/* Pièce jointe, on va dire que notre fichier s'appelle bidule.doc et qu'il se situe dans le répertoire courant */
//$fichier=file_get_contents('Doc1.doc');
$fichier1 = fopen("Doc1.doc", "r");
$attachement = fread($fichier1, filesize("Doc1.doc"));
$attachement = chunk_split(base64_encode($attachement));
fclose($fichier1);
/* On utilise aussi chunk_split() qui organisera comme il faut l'encodage fait en base 64 pour se conformer aux standards */
$fichier=chunk_split( base64_encode($attachement) );
//Écriture de la pièce jointe
$body.="--" .$boundary. "\n";
$body.="Content-Type: application/msword; name="Doc1.doc"\r\n";
$body.="Content-Transfer-Encoding: base64\r\n";
$body.="Content-Disposition: attachment; filename="Doc1.doc"\r\n";
$body.="$fichier";
//Fermeture de la frontière
//j'ai essayé avec et sans la fermeture de la frontière à ce niveau
//$body.= "--" . $boundary ."--";
//Fermeture de la frontière
$body.= "--" . $boundary ."--";
//Envoi du mail
if(mail("sedhob1@yahoo.fr", "TEST", $body, $headers)){ echo'envoyer';}else{echo'ERREUR';}