I have this script below that i would like to tweak so it can do two things:
- Send emails to multiple addresses (right now it only works if one email address is being sent an email.
- In the “to” field it should not display all others who have received the same notification. So each email should feel individual.
Code:
//Query to get emails
//$share_to comes from a drop down selection of users.
//it could be 1 person or multiple people.
//The way its stored in the field is this way user1,user2,user3,user4 or if one person then just user1.
$sql = "SELECT email_address from accounts
WHERE person_id='$share_to'";
$result = mysql_query($sql);
$query = mysql_query($sql) or die
("Error: ".mysql_error());
if ($result == "")
{
echo "";
}
echo "";
$rows = mysql_num_rows($result);
if($rows == 0)
{
print("");
}
elseif($rows > 0)
{
while($row = mysql_fetch_array($query))
{
$email = htmlspecialchars($row['email_address']);
print("");
}
}
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$headers .= "From: $usermail\r\n";
$headers .= "BCC: $email\r\n";
$to = "support@domain.com"; //the mail in the "TO", visible to all.
there has to be 1.
$subject = "$fullname Asked you something";
$message = "<html><body>";
$message .= "Hi!, <br><br>$fullname asked you something.<br><br>";
$message .= "<a href=www.domain.com/login.php>Click here to login.</a><br><br>";
$message .= "Please reply to this email if you have any questions.<br><br>Thanks,
<br><br>Abe<br>";
$message .= "<img src=www.domain.com/images/logohop.png /><br><br>";
$message .= "</body></html>";
mail($to, "Subject: $subject",
$message, "$headers" );
echo "";
1 Answer