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 38 39 40 41 42 43 44 45 46
| <?php
function mail_attachement($to , $bcc , $sujet , $message , $fichier , $typemime , $nom , $reply , $from){
$limite = "_parties_".md5(uniqid (rand()));
$mail_mime = "Date: ".date('l j F Y, G:i')."\n";
$mail_mime .= "MIME-Version: 1.0\n";
$mail_mime .= "Content-Type: multipart/mixed;\n";
$mail_mime .= " boundary=\"----=$limite\"\n\n";
//le fichier
$attachement = "------=$limite\n";
$attachement .= "Content-Type: $typemime; name=\"$nom\"\n";
$attachement .= "Content-Transfer-Encoding: base64\n";
$attachement .= "Content-Disposition: attachment; filename=\"$nom\"\n\n";
$fd = fopen( $fichier, "r" );
$contenu = fread( $fd, filesize( $fichier ) );
fclose( $fd );
$attachement .= chunk_split(base64_encode($contenu));
$attachement .= "\n\n\n------=$limite\n";
return mail($to, $sujet, $texte.$attachement, "Reply-to: $reply\nFrom: $from\nBcc: $bcc\n".$mail_mime);
}
?>
<?php
$adresse_exp = 'adresse@hotmail.fr';
$adresse_dest = 'adresse2@hotmail.fr';
$adresse_dest2 = 'adresse3@hotmail.fr';
$sujet = 'email';
$texte = "cette zone de texte n'est pas recu par le destinataire";
$cheminfichier = 'image.jpg;
$nomfichier = image.jpg';
$mimeType = 'text/plain';
$replyto = ""; // peut être nul
mail_attachement($adresse_dest, $adresse_dest2, $sujet , $texte , $cheminfichier , $mimeType , $nomfichier , $replyto , $adresse_exp);
?> |
Partager