Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/204154-multiple-emails/
Share on other sites

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

 

 

Link to comment
https://forums.phpfreaks.com/topic/204154-multiple-emails/#findComment-1069278
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/204154-multiple-emails/#findComment-1069675
Share on other sites

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

 

Link to comment
https://forums.phpfreaks.com/topic/204154-multiple-emails/#findComment-1070020
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.