2011-09-14 29 views
0

即時通訊循環產生一封電子郵件,我希望它發送每個獨特的項目給一個獨特的人。

我發現,當我使用$ mail-> AddAddress時,下次它循環,它只是添加地址,包括前面循環中的所有收件人,並將它們全部發送出去。

如何重置地址變量?

 loop(xtimes){ 

     [generate customer $message] 

     $mail->Host  = "smut.blabla.com"; 
     $mail->port = 25; 
     $mail->AddReplyTo('[email protected]', 'test name'); 
     $mail->AddAddress($currentEmployeeEmail); 
     $mail->SetFrom('[email protected]', 'test name'); 
     $mail->Subject = "Your Daily Report, for $currentEmployee - $reportDate"; 
     $mail->MsgHTML($message); 
     $mail->AddAttachment('logo_white.png'); 
     $mail->Send(); 
     } 

是否有與SetAddress相同的內容?

回答

3

,如果你在循環的開始創造什麼新的郵件,如:

$mail = new PHPMailer(); 

如果我沒記錯,還有一個ClearAddresses方法,如:

$mail->ClearAddresses(); 
0

您可以使用:

$mail->ClearAllRecipients()