Ok so I don't understand why this won't work consistently. The code does send the mail, but I randomly won't get 1 2 or all 3 emails. For testing I only have 3 emails in the table with three different addresses. If I try it one time I'll get the first and last email in the list, then next time just the last one and another time only the second one in the list. There seems to be no pattern to what I get. I am using a while loop and have echoed out the emails within the loop to see if it gets all three and everytime it does but still with random results of receiving them. Is there a better way or what. I have been at this for hours and tried a for loop but I really don't understand that and I'm not sure how to use a foreach loop either.PHP Code:$get_mail = mysql_query("SELECT emaile, name, lname FROM fam_info");
while ($mail = mysql_fetch_array($get_mail))
{
$emaile = $mail['emaile'];
$name = $mail['name'];
$lname = $mail['lname'];
$headers = 'From: System Admin <noreply@domain.com>';
$to = "$emaile";
$from = "Posted Events for Cousins@amewebdesigns.com/cousins";
$subject = "A cousins event has been posted for you to attend!";
$signature = "Thank you from all your cousins!";
$body = "Dear $name $lname,\r\n You have been invited to attend the event \"$title\" set to be held on $eventdate.\r\n";
if ($rsvp=="yes")
{
$body .= "RSVP's have been requested of you so please logon to the website and submit your RSVP.\r\n";
}
$body .= "For full details about the event please logon to the website.\r\n\r\n";
$body .= "$signature";
mail ($to, $subject, $body, "From: $from");
}



Reply With Quote


Bookmarks