i am trying to write a script that will send out an email to all the email addresses stored in a mysql db when the site has been updated. the code i have so far is as follows
$sql= "INSERT INTO $table (date, title, article) VALUES ('$a', '$b', '$c')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
$lastid = mysql_insert_id();
$message .= '<body leftmargin="0" topmargin="0">
<table width="700" border="0" align="center" cellpadding="0" cellspacing="5">
<tr>
<td>The ' . $table . ' section of the <a href="piponline.info"> PiPonline website</a> has been updated. Please follow the link to see the new content.
</tr>
</table>
</body>';
$query = "SELECT email FROM emails";
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result)){
$contactemail = $row['email']. ", ";
}
// Contacts
//$replyName = $merc_replyId;
//$replyEmail = $merc_replyAddress;
$replyName = "PiPonliine";
$replyEmail = "info@piponline.info";
$contactname = "";
// Subject
$subject = "Website Update";
// Headers
$headers = "MIME-Version: 1.0" . PHP_EOL;
$headers .= "Content-type: text/html; charset=iso-8859-1" . PHP_EOL;
$headers .= "From: ".$replyName." <".$replyEmail.">\r\n" . PHP_EOL;
$headers .= "BCC: ".$contactname." <".$contactemail.">\r\n" . PHP_EOL;
mail(implode(',', $contactemail), $subject, $message, $headers);
echo "$contactemail";
echo "<h2>Email notification sent</h2>";
echo "<h2>1 record added</h2>";
mysql_close($con);
this code is giving me the following error message which as far as i know means that array is not being populated.
Warning: implode(): Bad arguments
due to the error the emails are not being sent even if the code for that section is correct or not.