Skip to content

Commit

Permalink
Fix for #757 status check before sending email
Browse files Browse the repository at this point in the history
  • Loading branch information
eSilverStrike committed Dec 21, 2017
1 parent d72439f commit 235ce6e
Showing 1 changed file with 8 additions and 25 deletions.
33 changes: 8 additions & 25 deletions public_html/lib-common.php
Expand Up @@ -3466,33 +3466,16 @@ function COM_mail($to, $subject, $message, $from = '', $html = false, $priority
{
global $_TABLES;

// Need to check email address to ensure they are not from accounts that have a status of locked or new email. If so we need to remove them so no email sent
// Need to check email address to ensure they are not from account that have a status of locked or new email. If so we need to remove them so no email sent
// Email addresses without accounts are not affected
if (is_array($to)) {
foreach($to as $key => $value) {
$email = $key;
// If no status exists then assume no user account and email is being sent to someone else (which is fine and should be sent)
$status = DB_getItem($_TABLES['users'], 'status', "email = '$email'");
if ($status == USER_ACCOUNT_DISABLED || $status == USER_ACCOUNT_LOCKED || $status = USER_ACCOUNT_NEW_EMAIL) {
unset($array[$key]);
}
}
if (count($to) > 0) {
return Geeklog\Mail::send($to, $subject, $message, $from, $html, $priority, $optional, $attachments);
} else {
return false;
}
$email = key($to);
// If no status exists then assume no user account and email is being sent to someone else (which is fine and should be sent like to new users)
$status = DB_getItem($_TABLES['users'], 'status', "email = '$email'");

if ($status == USER_ACCOUNT_DISABLED || $status == USER_ACCOUNT_LOCKED || $status == USER_ACCOUNT_NEW_EMAIL) {
return false;
} else {
$email = $to;
// If no status exists then assume no user account and email is being sent to someone else (which is fine and should be sent)
$status = DB_getItem($_TABLES['users'], 'status', "email = '$email'");

if ($status != USER_ACCOUNT_DISABLED && $status != USER_ACCOUNT_LOCKED && $status != USER_ACCOUNT_NEW_EMAIL) {
return Geeklog\Mail::send($to, $subject, $message, $from, $html, $priority, $optional, $attachments);
} else {
return false;
}

return Geeklog\Mail::send($to, $subject, $message, $from, $html, $priority, $optional, $attachments);
}
}

Expand Down

0 comments on commit 235ce6e

Please sign in to comment.