Jump to content

send notification email


doddsey_65

Recommended Posts

i have the following which sends an email whenever a post is made within the topic the user is subscribed to.

However it still sends the email to the person who made the reply. I need to take out the email of the poster if they are in the notification list. This is what i have but it doesnt seem to remove them.

 

$notification_query = $db->query("SELECT 
												u.user_id, 
												u.user_email, 
												u.user_username,
									 n.notification_user_id

									 FROM ".DB_PREFIX."members as u

									 LEFT JOIN ".DB_PREFIX."notifications as n
									 ON n.notification_user_id = u.user_id

									 WHERE n.notification_topic_id = '$post_id'")
									 or trigger_error("SQL", E_USER_ERROR);

$num_rows = mysql_num_rows($notification_query);
while ($notification_list = mysql_fetch_object($notification_query)) {
$users4[] = $notification_list->user_email; 
}

$emailAddress = implode(', ', $users4);

if (in_array($_SESSION['user_username'], $emailAddress))
{
$emailAddress = str_replace($_SESSION['user_username'], ' ', $emailAddress);
}
if ($num_rows >=1) {

putenv('TZ=EST5EDT'); 
    $headers  = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    $headers .= 'From: [email protected]' . "\r\n";

    $message .= "A Reply Has Been Made To {$_POST['subject']}.<br /><br />";

$message .= "You are receiving this message because you have subscribed
to the topic {$_POST['subject']},<br /> which has a new post since your last one.<br />";
$message .= "Click the link below to view the new thread now.<br />";
$message .= "<a href=\"{$site_root}/index.php?forum={$forum_id}\">
{$site_root}/index.php?forum={$forum_id}&topic={$thread_topic_id}</a><br />
<br />To Unsubscribe from this topic visit the link below.<br /><br />
<a href=\"{$site_root}/subscribe.php?forum={$forum_id}&topic={$topic_id}&uid={$notification_list->user_id}&do=unsubscribe\">
{$site_root}/subscribe.php?forum={$forum_id}&topic={$topic_id}&uid={$notification_list->user_id}&do=unsubscribe</a><br /><br />
Thanks";
$subject = "A Reply Has Been Made To {$_POST['subject']}.";
    mail($emailAddress,$subject,$message,$headers);

}
				}

Link to comment
https://forums.phpfreaks.com/topic/217182-send-notification-email/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.