PHPmailer - Multiple sending of e-mail

前端 未结 2 1739
无人及你
无人及你 2020-12-30 17:03

I am sending emails using PHPmailer. As of now, I am successful in sending email to one address. Now, I want to send multiple emails in just one click.

PROBL

2条回答
  •  悲哀的现实
    2020-12-30 17:22

    After you send an email $mail->Send(), execute this:

    $mail->ClearAllRecipients();
    

    in your while loop.
    So your basic while loop structure looks like this:

    while($row = mysql_fetch_assoc($p_address)){
    
        $mail->AddAddress($row['email_address']);
        $mail->AddAttachment("fpdf/pdf_reports/document/".$ctrl_no.".pdf");
        $mail->send();
        $mail->ClearAllRecipients(); 
        $mail->ClearAttachments();   //Remove all attachements
    
    }
    

提交回复
热议问题