php - Sending recipent specific emails -


i have situation.

i beginner @ programming. want send email users based on list of $to array. if $to has similar array elements data sent 1 user. if $to has different elements, data sent different elements of $to array $to specific data.

please me out.

below code :- have array of $to. need separate emails based on number of unique elemets in $to.

    if ($category!="tool"){           $accessemailbody = "\n<p>please provide $reqfname $reqlname ($reqwinid) access following per attached approval: </p>\n<blockquote>";         $accessemailbody = "<p>hello $displayname ,</p>$accessemailbody\n\t<ul>";         foreach (array_values($wgs) $wg) {             list($wgname, $wgcategory, $wgid) = $wg;                       if ($to == ''){                     $to = $current->getwgemailbycatid($wgcategory);                 }               $accessemailbody .= "<li>";             $accessemailbody .= "(". trim($current->getwgcatenamebyid($wgcategory)). ")";             $accessemailbody .= " $wgname</li>             <ul>";             $rows = $current->getwgdetails($wgid);              while ($line = mssql_fetch_row($rows)){                      $accessemailbody .= "<li><b>".$current->getwgresourcetype($line[0]).":</b> $line[1]</li>";             }             $accessemailbody .="</ul>";         }         $accessemailbody .= "\n\t</ul>";          $accessemailbody .= "\n</blockquote>\n<p>thank you.<br/>cralt admin</p>\n".$body;           if (isset($to)){             return mail($to, $subject, $accessemailbody, $header);         } else {             return 0;         }     }  

this basic outline of think need. you'll need fill out other fields of email function itself...

$to_array = array('john', 'jeff', 'frank', 'bill', 'frank'); $uniqueelems = array();  // loop make new array of unique elements foreach($to_array $original_elem){      if ( ! in_array($original_elem, $uniqueelems)) {         $uniqueelems[] = $original_elem; }  }   // loop through array of unique addresses , send them email foreach($uniqueelems $addr){      mail($addr,$subject,$message,$headers,$parameters);  } 

Comments

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -