Send Email to ALL except the sender/posting user

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
ninethousandfeet
Forum Contributor
Posts: 130
Joined: Tue Mar 10, 2009 4:56 pm

Send Email to ALL except the sender/posting user

Post by ninethousandfeet »

okay, so my users are involved in conversations with other users... when a user posts a comment in an existing conversation, all the people involved in the conversation receive an email along the lines of: "hey, you have a comment in this conversation. go login!" ... the way i have it right now, the email also goes to the sender (the user posting this comment)... any way for me to minus their username from the mail()?
i'm open to suggestions, thank you for reading this!

Code: Select all

 
$var8_getALLemails = "-1";
if (isset($_GET['comment_title'])) {
  $var8_getALLemails = $_GET['comment_title'];
}
mysql_select_db($database_connUser, $connUser);
$query_getALLemails = sprintf("SELECT userTable.user_id, userTable.username, userTable.email, testComment.user_id, testComment.comment_id, testComment.comment_title FROM userTable INNER JOIN testComment ON userTable.user_id = testComment.user_id OR userTable.user_id = testComment.comment_id  WHERE testComment.comment_title = %s GROUP BY userTable.email", GetSQLValueString($var8_getALLemails, "text"));
$getALLemails = mysql_query($query_getALLemails, $connUser) or die(mysql_error());
$row_getALLemails = mysql_fetch_assoc($getALLemails);
$totalRows_getALLemails = mysql_num_rows($getALLemails);
do { 
$username = $row_getALLemails['username'];
$email = $row_getALLemails['email'];
$comment = $row_getALLemails['comment_title'];
 
$subject = "New comment";
$message = "Hello, $username!
You have a NEW comment in this conversation: 
-- $comment.
Login at http://www.mysite.com.
Thank you,
ME
--This is an automated response, please do not reply--";
 
mail($email, $subject, $message, 'From: ME');
} while ($row_getALLemails = mysql_fetch_assoc($getALLemails));
 
Post Reply