Hi all,
Im trying to send an email to multiple addresses, so I wrote function that pulls the emails from the database, and separates each one with a comma, but the mailing part keeps failing. However a similar function as getmails() is working on another page, so I am really lost as to what I am doing wrong. Here is my code, any help will be appreciated.
Thanks all.
function getmails()
{
$id = mysql_query("SELECT * FROM subscribes ORDER BY subscribe_id DESC") or die(mysql_error());
$elements = array();
while( $activeArray=mysql_fetch_array($id) )
{
$elements[] = $activeArray['subscribe_email'] ;
}
$main = implode(', ', $elements);
print $main;
}
function announce() {
if( isset( $_POST['announce'])) {
$ToEmail = getmails();
$EmailSubject = "".$_POST['title']."";
$mailheader .= "From: [email protected]\r\n";
$mailheader = "Reply-to:".$_POST['author']."@subdomain.domain.com\r\n";
$mailheader = "Content-type: text/html; charset=iso-8859-1\r\n";
$MESSAGE_BODY = "Author: ".$_POST['author']."<br>";
$MESSAGE_BODY = "Newsletter: ".$_POST['content']."<br>";
mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure");
}
}