I have built a web utility which send me an email as a reminder a few days before an event occurs. The problem is that if 3 emails are sent, the 3rd email will have the From email address in the header 3 times. How do I avoid this? Better still, how would I have just 1 email sent containing all the events that are coming up (rather than sending 1 for each event). The mail code is below:
for ($i=0; $i<$num_results; $i++)
{
$row = mysql_fetch_array($result);
$first = $row['first_name'];
$last = $row['last_name'];
$type = $row['type'];
$bd = $row['date'];
$toaddress = "main email address";
$subject = "Your Events Reminder";
$mailcontent = "Here is important event coming up in the next few days that you might not want to forget.\n\nName: " . $first . " " . $last . "\n\n" . "Date: " . $bd . "\n\n" . "Event: " . $type;
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/plain; charset=iso-8859-1\r\n";
$headers .= "From: \r\n";
$headers .= "Cc: 2nd email address\n";
mail($toaddress, $subject, $mailcontent, $headers);
}
for ($i=0; $i<$num_results; $i++)
{
$row = mysql_fetch_array($result);
$first = $row['first_name'];
$last = $row['last_name'];
$type = $row['type'];
$bd = $row['date'];
$toaddress = "main email address";
$subject = "Your Events Reminder";
$mailcontent = "Here is important event coming up in the next few days that you might not want to forget.\n\nName: " . $first . " " . $last . "\n\n" . "Date: " . $bd . "\n\n" . "Event: " . $type;
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/plain; charset=iso-8859-1\r\n";
$headers .= "From: \r\n";
$headers .= "Cc: 2nd email address\n";
mail($toaddress, $subject, $mailcontent, $headers);
}