php - Multiple sending of email with attachment - repost -


i re-posting because no 1 answered previous post.

i trying send emails multiple recipients respective pdf files attached. successful sending emails multiple recipient recipients receive multiple emails. number of emails received recipient number of email addresses stored in database.

the second problem have encountered attachment sent recipients same file. scenario should this: recipient should have email attached pdf a, recipient b pdf b, on , fort.

those pdf's have file names correspond unique control number each recipient has. e.g. recipient has control number 1234, pdf named 1234.pdf.

i tried wile loop in $ctrl_no = mysql_result($ctrl, 0) gives error saying memory limit of server has reached.

hope solve 2 problems.

$input = addslashes($_post['dep']);                                                                                                       $email = "select email_address  student y y.center = '$input'";    if ($p_address=mysql_query($email)) {    while($row = mysql_fetch_array($p_address))  {        $mail->addaddress($row[0]);   $input = addslashes($_post['dep']);                            $control = "select control_no  student y y.center = '$input'";   if($ctrl=mysql_query($control)){   $ctrl_no = mysql_result($ctrl, 0);    $mail->addattachment("reports/".$ctrl_no.".pdf");      }   else{     echo "no attached pdf.";    } 

update: $mail function

require_once('phpmailer/class.phpmailer.php'); include("phpmailer/class.smtp.php");   $mail             = new phpmailer();  $body             = file_get_contents('phpmailer/body.html'); $body             = preg_replace('/\/b]/','',$body);  $mail->issmtp();  $mail->host       = "smtp.gmail.com";  $mail->smtpdebug  = 1;                     $mail->smtpauth   = true;                   $mail->smtpsecure = "tls";                  $mail->host       = "smtp.gmail.com";       $mail->port       = 587;                    $mail->username   = "me@gmail.com";   $mail->password   = mypass;             $mail->setfrom("me@gmail.com", "office");  $mail->addreplyto("me@gmail.com"," office");  $mail->subject    = "my subject";  $mail->altbody    = "subject file";  $mail->msghtml($body); 

you can't send different attachments different recipients in 1 email. need send separate emails.


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -