Send mail to multiple users
Posted: Sun Jan 23, 2011 6:51 am
Hello, i need to send an email to multiple users. but the problem is that i need to parse a string instead of an array, can any1 help me to solve this problem?
The error is:
Warning: mail() expects parameter 1 to be string, array given in C:\wamp\www\newsletter.php on line 25
my code is:
The error is:
Warning: mail() expects parameter 1 to be string, array given in C:\wamp\www\newsletter.php on line 25
my code is:
Code: Select all
$db_hostname="localhost";
$db_username="root";
$db_password="";
$db = mysql_connect($db_hostname,$db_username,$db_password);
if (!$db)
{
die("Could not connect: " . mysql_error());
}
mysql_select_db("newsletter", $db);
if (isset($_POST['categories']))
{ //make the checkmarks with name categories[]
foreach ($_POST['categories'] as $cat)
{
$email_query = mysql_query("SELECT email FROM members WHERE `category` = '" . $cat . "'");
if (mysql_num_rows($email_query))
{
while ($email = mysql_fetch_array($email_query))
{
ini_set('SMTP','smtp.orange.mu');
if (mail($email, 'Test','This is a test', "From: <noreply@domain.com>"))
{
echo "Message Sent";
}
else
{
echo "Message Not Sent";
}
}//end while
}// end if
}
}