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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
| <?php
include("../Template/Connect/Connexionbd.php");
echo '<a href="admin/admin_menu.php">retour Menu</a><br><br>';
$img_dep="aurachrome/aff1.jpg";
$Css ='
body{ margin: 0;padding: 0;font-family: Georgia, "Times New Roman", Times, serif;} ';
$Texte2 = 'Voici mon texte ';
//sujet
$titre = 'NewsLetter - ';
$sujet = utf8_decode( $titre.'la compagnie');
// Recup Nom & Mail expediteur
$Res_Exp = mysql_query ("select * from User_Exp");
$Nom_Exp = mysql_result($Res_Exp,0,"Nom_Exp");
$Mail_Exp = mysql_result($Res_Exp,0,"Mail_Exp");
// Recup Destinataire
$sql = "SELECT * FROM User_Dest";
$req = mysql_query($sql) or die('Erreur SQL !<br/>'.$sql.'<br/>'.mysql_error());
$boundary = "-----=".md5(uniqid(rand()));
$headers = 'From: '.$Nom_Exp.' <'.$Mail_Exp.'>'."\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: multipart/mixed; boundary=\"$boundary\"";
$headers.="\n";
$contenu_mail = "--" . $boundary . "\n";
$contenu_mail .= "Content-Type: text/plain; charset=\"iso-8859-1\"\n";
$contenu_mail .= "Content-Transfer-Encoding: 8bit\n\n";
$contenu_mail .= "Test texte \n\n";
$contenu_mail .= "--" . $boundary . "\n";
$contenu_mail .= 'Content-Type: text/html; charset="iso-8859-1"'."\n";
$contenu_mail .= 'Content-Transfer-Encoding: 8bit'."\n\n";
$contenu_mail .= '<html><head><title>Test</title><style type="text/css" media="screen">'.$Css.'</style></head><body>'.utf8_decode($Texte2).'</body></html>'."\n\n";
$contenu1 .= "--" . $boundary . "\n";
$contenu1 .= 'Content-Type: text/html; charset="iso-8859-1"'."\n";
$contenu1 .= 'Content-Transfer-Encoding: 8bit'."\n\n";
$contenu1 .= '<html><head><title>Test</title><style type="text/css" media="screen">'.$Css.'</style></head><body>'.utf8_decode($Texte1).'</body></html>'."\n\n";
$contenu_img .= "--" . $boundary . "\n";
// -- LECTURE DU FICHIER IMAGE + CONVERSION CONTENUE --
$open=fopen($img_dep,'r'); // "b"
$img=fread($open,filesize($img_dep));
$img=chunk_split(base64_encode($img));
fclose($open);
$nom_img=basename($img_dep);
$contenu_img .= "Content-Type: image/jpeg; name=\"$nom_img\"\n";
$contenu_img .= "Content-Transfer-Encoding: base64\n";
$contenu_img .= "Content-Disposition: attachement; filename=\"$nom_img\"\n\n"; //INLINE
//$contenu_img .= chunk_split(base64_encode(file_get_contents('$nom_img')))."\n"; // encodage du pdf
$contenu_img .= "\n\n";
$contenu_img .=$img."\n";
$contenu_img .="\n\n";
//$contenu_img .= "--" . $boundary . "--\n";
while($Dest=mysql_fetch_assoc($req))
{
// destinataire
$destinataire = $Dest["Mail_Dest"];
if (mail( $destinataire,$sujet,$contenu_mail.$contenu_img,$headers))
{echo $destinataire." OK <br/>";}
else
{echo $destinataire." NG <br/>";}
}
?> |
Partager