} } if ($mass) { while (!$plproxy->val("SELECT COUNT(*) FROM messages(?) WHERE id = ?", $sender['uid'], $message_id)) { echo "Wait PGQ (10 seconds)...\n"; sleep(10); } $res = $plproxy->query("SELECT * FROM messages_zeros_userdata(?, ?)", $sender['uid'], $message_id); } else { $res = $master->query($sql); } echo "Send email messages\n"; $count = 0; $smtp = new SMTP(); if (!$smtp->Connect()) { die("Don't connect to SMTP\n"); } while ($user = pg_fetch_assoc($res)) { if (empty($user['email']) || !is_null($eSubscr) && substr($user['subscr'], $eSubscr, 1) == '0') { continue; } $smtp->recipient = $user['uname'] . " " . $user['usurname'] . " [" . $user['login'] . "] <" . $user['email'] . ">"; $smtp->subject = preg_replace("/\\{\\{([-_A-Za-z0-9]+)\\}\\}/e", "\$user['\\1']", $eSubject); $smtp->message = preg_replace("/\\{\\{([-_A-Za-z0-9]+)\\}\\}/e", "\$user['\\1']", $eMessage); if ($count > 0 && $count % $printStatus == 0) { echo "Working... {$count} emails sended\n"; } $smtp->SmtpMail('text/html'); $count++; } echo "OK. Total: {$count} users\n";