Dear All,
I have the following script which is supposed to send Birthday Wish email. There might be single or multiple recipient on the same day which will be in TO field. Whereas all other email address in the database would be send a CC. The issue is that the echo of the $ccaddr works fine and prints all other email address from database but does not include in the CC header of the email and sends email to the last address in the mysql database…
Any help would be appreciated as im a newbie to php…
"; echo "$name
"; echo "$num1
"; $num=mysql_numrows($result); $i=0; echo "CC: "; while ($row = mysql_fetch_array($result)) : if ($i< $num) { $ccaddr=mysql_result($result,$i,"email"); echo "$ccaddr; "; $i++; } else { echo "NO CC ADDRESS FOUND"; } endwhile; //Set mail variables $subject .= "Birthday Wishes\n"; $headers .= "Content-Type: text/html; charset=iso-8859-1\n"; $headers .= "From: [email protected] \n"; $headers .= "Reply-to: [email protected] \n"; $headers .= "CC: $ccaddr; \n"; $mailBodyText = <<<HHHHHHHHHHHHHH Dear $name
We would like to take this opportunity to wish you a VERY HAPPY BIRTHDAY HHHHHHHHHHHHHH; //send mail mail($recipientAddr, $subject, $mailBodyText, $headers); mysql_free_result($result); echo "email sent successfully
"; ?>