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
| $dest = "toto@titi.com";
$reponse = "tutu@toto.net";
$expediteur = "tata@tutu.com";
$nomExpediteur = "toto";
$sujet = "test";
$message_texte='Bonjour,'."\n\n".'Voici un message au format texte';
$message_html ="<html><head><title>Un titre ici</title></head><body bgcolor='#AAAAAA'>Un <a href='http://www.toto.fr'>message</a> <b>de</b> <i>test</i></body></html>";
$boundary = uniqid("TOTO");
$headers ='From: "'.$nomExpediteur.'"<'.$expediteur.'>'."\n";
$headers .='Reply-To: '.$reponse."\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: multipart/alternative; boundary = $boundary\r\n\r\n";
$headers .= "This is a MIME encoded message.\r\n\r\n";
$headers .= "--$boundary\r\nContent-Type: text/plain; charset=ISO-8859-1\r\nContent-Transfer-Encoding: base64\r\n\r\n";
$headers .= chunk_split(base64_encode($message_texte));
$headers .= "--$boundary\r\nContent-Type: text/html; charset=ISO-8859-1\r\nContent-Transfer-Encoding: base64\r\n\r\n";
$headers .= chunk_split(base64_encode($message_html));
$fd=fopen ("img.jpg", "rb");
$FileContent=fread($fd,filesize("img.jpg"));
fclose ($fd);
$FileContent = chunk_split(base64_encode($FileContent));
$headers .= "--$boundary\r\nContent-Type: application/octetstream; name=\"img.jpg\"\nContent-Transfer-Encoding: base64\r\n\r\n";
$headers .= "Content-Disposition: attachment; filename=\"img.jpg\"\r\n\r\n";
$headers.= $FileContent."\n";
$headers .= "--$boundary\r\n";
mail($dest,$sujet,"", $headers); |
Partager