Envoi multi destinataires avec PHPMailer

Résolu/Fermé
markaz Messages postés 330 Date d'inscription mercredi 18 avril 2007 Statut Membre Dernière intervention 16 septembre 2015 - 25 juil. 2013 à 17:25
markaz Messages postés 330 Date d'inscription mercredi 18 avril 2007 Statut Membre Dernière intervention 16 septembre 2015 - 25 juil. 2013 à 18:17
Bonjour, je veux envoyer un mail à plusieurs mail stocké dsn ma BDD avec PHPMailer. Mais j'ai un souci.
Mon code:
$mail = new PHPmailer(); //instantiation de la classe PHPMailer
$mail->SetLanguage('en','language/'); 
$mail->IsSMTP();
$mail->Host='mon_host'; 
$mail->SMTPAuth = true; 
$mail->Username = 'mon_email'; 
$mail->Password = '?mon_password'; 
$mail->CharSet = 'UTF-8'; 
$mail->From ='mon_email'; 
$mail->FromName = 'Nom_emeteur';
$mail->Username = 'user_name';
 
//requete de recuperation des email
$sqlMail = $connect_db->prepare("SELECT * FROM email");
$sqlMail->execute();
$tab = array();
 
while($dataMail = $sqlMail->fetch(PDO::FETCH_OBJ))  {
 
   $tab[] = $dataMail;
 
    foreach($tab as $cle => $val){
	$mail->AddBCC(implode($val,''), ',' );
    }
}
 
$mail->AddReplyTo('mail_de_reponse'); 
$mail->Subject=$_POST['titre']; 
 
 
//Corps du message
$mail->Body='<html><body><head><style>.entete{.entete{width:630px; height:100px;}.contenu{border: solid 1px #D7D7D7; width: 630px; height:auto; padding:5px; margin-bottom=10px; margin-top:90px;}';
$mail->Body.='.footer{font-family:Georgia, "Times New Roman", Times, serif; font-size:11px; margin-top: 15px;}a {color:#0486c4;}.gris{background-color:#d7d7d7;}';
$mail->Body.='</style></head>';
$mail->Body.='<div style="background-image:url(https://www.000webhost.com/migrate?static=true width:630px; height:100px;" /><br />';
$mail->Body.='<div class="contenu">'.$_POST['message'].'<br /><br /><br /><div style="width:90%; margin= 10px 0 10px 0"><b>Ce mail vous est envoyé par l\'équipe d\'administration du Portail de Sciences & Progrès, merci de ne pas y répondre</b></div>';
$mail->Body.='</div><div class="footer">';
$mail->Body.='©Sciences & Progrès - Tous droits réservés. |';
$mail->Body.='<a rel="nofollow" target="_blank" href="#">Vous désabonner de cette newsletter</a></div></body></html>'; 
 
if(!$mail->Send()){ 
	echo $mail->ErrorInfo;  
}
$mail->SmtpClose(); 
unset($mail);


Erreur:
Warning: implode(): Invalid arguments passed in D:\EasyPHP-12.1\www\gestion-newsletter\_ajouter.php on line 92
SMTP Error: The following recipients failed: , ,


NB: Pour l'envoi à un seul mail ça fonctionne sans problème.

1 réponse

markaz Messages postés 330 Date d'inscription mercredi 18 avril 2007 Statut Membre Dernière intervention 16 septembre 2015 5
25 juil. 2013 à 18:17
Mon problème était sur l'adresse smtp.
0