this is my code
foreach($Lid as $idP=>$idpersonne)
{$model2=Null;
$Person=new Personne;
$Person=Personne::model()->findByPk($idpersonne);
if(!empty($Person))
{
$model2=new Sendemail;
$model2->idobjet=$MessageId;
$model2->idpersonne=$idpersonne;
$model2->adremail=$Person->email;
$model2->statut=0;
$model2->dateenvoi=date('Y-m-d');
$model2->datereception="";
$model2->body='Bonjour '.$Person->nom.''.$Person->prenom.'</br> '.$model->body;
$model2->sujet=$model->sujet;
if($model2->save()){
$this->mailsend($model2->adremail,Yii::app()->params['adminEmail'],$model2->sujet,$model2->body,$path);}
}
}
when I send email users get all messages I means thes recieve theirs messages and messaage of others why?! I am sure the problem is with mailsend
and their is the code I am using smtp mailer
public function mailsend($to,$from,$subject,$message,$attachement)
{
$mail=Yii::app()->Smtpmail;
$mail->IsSMTP();
$mail->SetFrom($from, ' ');
$mail->Subject = $subject;
$mail->AddAddress($to, "");
$mail->AltBody = 'To view the message, please use an HTML compatible email viewer!';
$mail->Body=$message;
$mail->IsHTML(true);
$mail->AddAttachment($attachement);
$mail->Send();
}
someone has any idea?!