clay1 Posted June 8, 2010 Share Posted June 8, 2010 I've got a script which emails a pdf as an attachment I am trying to convert it to send multiple emails to different addresses from a handful of arrays To explain further: I have 14 arrays that will be converted into 14 different pdfs to be emailed to 14 different email addresses When I get to the point in the script where it would normally send off the 1 email I am trying to put that inside a loop so that after it sends the first it continues to through the rest of the arrays but I am having trouble figuring out how to get it to work properly. Any suggestions on how to go about this in an efficient manner? To be clear I'm not trying to add a second email address to 1 email.. I am trying to Create the email, send it and then loop back to send a different email to a new address Quote Link to comment https://forums.phpfreaks.com/topic/204154-multiple-emails/ Share on other sites More sharing options...
kenrbnsn Posted June 8, 2010 Share Posted June 8, 2010 Code? Quote Link to comment https://forums.phpfreaks.com/topic/204154-multiple-emails/#findComment-1069275 Share on other sites More sharing options...
clay1 Posted June 8, 2010 Author Share Posted June 8, 2010 Right now I have arrays containing the data that will be converted to PDF while ($recordData = pg_fetch_assoc($recordresults)) { if ($recordData['event city'] == 'Birmingham' || in_array($recordData['zip/postal code'], $birminghamzips)){ $birmingham[] = $recordData;} elseif ($recordData['event city'] == 'Bridgewater' || in_array($recordData['zip/postal code'], $bridgewaterzips)){ $bridgewater[] = $recordData;} Then I created another array that holds those arrays: i.e: $profilearray = array("birmingham" => $birmingham,"bridgewater" => $bridgewater The original version of the script normally will take a set of records and convert them to PDF: while($myrow = pg_fetch_assoc($result)) { $pdf->AddPage(); PDF layout code email to: [email protected] } I'm trying to place that inside a loop so that it happens once for each of the arrays that I have Quote Link to comment https://forums.phpfreaks.com/topic/204154-multiple-emails/#findComment-1069278 Share on other sites More sharing options...
clay1 Posted June 8, 2010 Author Share Posted June 8, 2010 Anybody? Quote Link to comment https://forums.phpfreaks.com/topic/204154-multiple-emails/#findComment-1069668 Share on other sites More sharing options...
kenrbnsn Posted June 8, 2010 Share Posted June 8, 2010 Show us your attempt to use a loop and tell us the problems you're having. Ken Quote Link to comment https://forums.phpfreaks.com/topic/204154-multiple-emails/#findComment-1069669 Share on other sites More sharing options...
clay1 Posted June 8, 2010 Author Share Posted June 8, 2010 I don't really have anything to show I tried doing a foreach or a while loop to try and set the email address such as: foreach($leadsarray as $filetoemail){ if(isset($birmingham)){ $email = '[email protected]; } elseif(isset($encino)){ $email = '[email protected]} but when print email it just prints [email protected] 14 times rather than each email address once but when I print out the loop I just get Quote Link to comment https://forums.phpfreaks.com/topic/204154-multiple-emails/#findComment-1069675 Share on other sites More sharing options...
clay1 Posted June 9, 2010 Author Share Posted June 9, 2010 Nobody can help with this? Seems like it should be pretty simple, I just need some direction Quote Link to comment https://forums.phpfreaks.com/topic/204154-multiple-emails/#findComment-1069989 Share on other sites More sharing options...
clay1 Posted June 9, 2010 Author Share Posted June 9, 2010 I think I've made some progress. I think I've made some progress. $marketsarray = array(array("birmingham", "bham@"), array("bridgewater", "bridgewater@"),array("coltsneck", "coltsneck@"), array("encino", "encino@"), array("grandrapids", "grandrapids@"),array("hackensack","hackensack@"), array("houston","houston@"),array("irvine","irvine@"),array("lawrenceville","lawrenceville@"),array("la", "la@"),array("nola","neworleans@"),array("palmbeach","palmbeach@"),array("pittsburgh","pittsburgh@"),array("upland", "upland@")); $leadsarray = array("birmingham" => $birmingham,"bridgewater" => $bridgewater, "coltsneck" => $coltsneck,"encino"=> $encino,"grandrapids"=> $grandrapids,"hackensack"=> $hackensack,"houston"=> $houston,"irvine"=> $irvine,"lawrenceville"=> $lawrenceville,"la"=> $la, "nola"=>$nola,"palmbeach"=> $palmbeach,"pittsburgh"=> $pittsburgh,"upland"=> $upland); $i = 0; while($i <13){ $market = $marketsarray[$i][0]; if(isset($leadsarray[$market])){ echo "<br>" . $marketsarray[$i][1]; echo "<pre>"; print_r($leadsarray[$market]); echo "</pre>"; } $i++; } This seems to be printing out the correct information with my test records I am going to wrap that loop around my pdf/email script now that I am getting the desired results Questions: Are there any issues that can be seen that might cause problems in the future? Or does this code look sound? I am going to wrap that loop around my pdf/email script now that I am getting the desired results Quote Link to comment https://forums.phpfreaks.com/topic/204154-multiple-emails/#findComment-1070020 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.