php - Phpmailer - Unique email attachments -
i trying send multiple emails unique attachment. currently, successful in sending multiple emails different addresses databases.
problem: whenever send emails, each email sent has multiple attachments.
what should be: email should have 1 unique attachment only. like, abc@gmail.com should have abc.pdf attached, bnm@gmail.com should have bnm.pdf attached, , etc.
so far, have code below. maybe it's in loop cause problem, or something. please comment if have idea. thanks.
$email = "select si.email_address, sr.control_no sa_student si left join sa_result sr on sr.control_no = si.control_no schoolyear = '2013' "; if ($p_address=mysql_query($email)) { while($row = mysql_fetch_array($p_address)) { $mail->addaddress($row['email_address']); $mail->addattachment("fpdf/pdf_reports/docu/".$row['control_no'].".pdf"); } $mail->send(); $mail->clearallrecipients(); $mail->clearattachments(); }
you have move clear
, send
methods while loop:
$email = "select si.email_address, sr.control_no sa_student si left join sa_sase_result sr on sr.control_no = si.control_no schoolyear = '2013' "; if ($p_address=mysql_query($email)) { while($row = mysql_fetch_array($p_address)) { $mail->addaddress($row['email_address']); $mail->addattachment("fpdf/pdf_reports/docu/".$row['control_no'].".pdf"); $mail->send(); $mail->clearallrecipients(); $mail->clearattachments(); } }
Comments
Post a Comment