echo "Send email messages\n";
$mail = new smtp();
$mail->subject = $eSubject;
// заголовок письма
$mail->message = $eMessage;
// текст письма
$mail->recipient = '';
// свойство 'получатель' оставляем пустым
$spamid = $mail->send('text/html');
if (!$spamid) {
    die('Failed!');
}
// с этого момента рассылка создана, но еще никому не отправлена!
// допустим нам нужно получить список получателей с какого-либо запроса
$i = 0;
$mail->recipient = array();
$res = $master->query($sql);
while ($row = pg_fetch_assoc($res)) {
    $mail->recipient[] = array('email' => $row['email'], 'extra' => array('first_name' => $row['uname'], 'last_name' => $row['usurname'], 'USER_LOGIN' => $row['login']));
    if (++$i >= 30000) {
        $mail->bind($spamid);
        $mail->recipient = array();
        $i = 0;
    }
    $cnt++;
}
if ($i) {
    $mail->bind($spamid);
    $mail->recipient = array();
}
echo "OK. Total: {$cnt} users\n";
示例#2
0
 /**
  * Функция рассылает сообщения
  * 
  * @global type $DB 
  */
 public function getMailerSend()
 {
     global $DB;
     $PLDB = new DB('plproxy');
     // @see type_send_regular == self::$TYPE_REGULAR;
     $sql = "SELECT \n                    mm.*, \n                \n                    mfe.type_account as etype_account, mfe.type_profile as etype_profile, mfe.from_regdate as efrom_regdate, mfe.to_regdate as eto_regdate, \n                    mfe.from_lastvisit as efrom_lastvisit, mfe.to_lastvisit as eto_lastvisit, mfe.type_sex as etype_sex, \n                    mfe.finance as {$this->subfilter[0]}, mfe.buying as {$this->subfilter[1]}, mfe.project as {$this->subfilter[2]}, mfe.massend as {$this->subfilter[3]},\n\n                    mff.type_account as ftype_account, mff.type_profile as ftype_profile, mff.type_portfolio as ftype_portfolio, mff.from_regdate as ffrom_regdate, \n                    mff.to_regdate as fto_regdate, mff.from_lastvisit as ffrom_lastvisit, mff.to_lastvisit as fto_lastvisit, mff.type_sex as ftype_sex, \n                    mff.finance as {$this->subfilter[4]}, mff.buying as {$this->subfilter[5]}, mff.project as {$this->subfilter[6]}, \n                    mff.specs as {$this->subfilter[7]}, mff.blogs as {$this->subfilter[8]}, mff.geo as {$this->subfilter[9]},\n                    mff.regdate_interval as fregdate_interval    \n\n                FROM mailer_messages mm\n                LEFT JOIN mailer_filter_employer as mfe ON mfe.id = mm.filter_emp\n                LEFT JOIN mailer_filter_freelancer as mff ON mff.id = mm.filter_frl    \n                WHERE \n                in_draft = false AND status_sending NOT IN(2,3) AND status_message = 0 AND\n                ( \n                    ( type_send_regular = 1 AND date_sending <= NOW() ) \n                        OR\n                    ( type_send_regular = 2 AND \n                      current_date + date_trunc('minute', date_sending)::time  <= date_trunc('minute', NOW()) AND \n                      type_send_regular = extract(ISODOW from NOW()) )\n                        OR\n                    ( type_send_regular = 3 AND \n                      extract('day' from date_sending) = extract('day' from NOW()) AND \n                      current_date + date_trunc('minute', date_sending)::time  <= date_trunc('minute', NOW()) )\n                        OR\n                    ( type_send_regular = 4 AND \n                      extract('month' from date_sending) = extract('month' from NOW()) AND \n                      extract('day' from date_sending) = extract('day' from NOW()) AND \n                      current_date + date_trunc('minute', date_sending)::time  <= date_trunc('minute', NOW()) )\n                )\n                ORDER BY (current_date + date_trunc('minute', date_sending)::time) ASC";
     $result = $DB->rows($sql);
     if (!$result) {
         return false;
     }
     $ids = array_map(create_function('$a', 'return $a["id"];'), $result);
     $this->log = new log('massend/massend-' . SERVER . '-%d.log', 'a', '%d.%m.%Y %H:%M:%S : ');
     // Переводим все рассылки в статус "Идет рассылка"
     $this->log->writeln("Sending messages - (" . count($ids) . ")");
     $this->update(array("status_sending" => 2), $ids);
     foreach ($result as $k => $message) {
         $this->log->writeln("Start sending message ID = {$message['id']}");
         foreach ($this->subfilter as $val) {
             if ($message[$val]) {
                 $message[$val] = unserialize($message[$val]);
             }
         }
         // Обрабатываем вложения
         $attached = array();
         if ($message['is_attached']) {
             $attached = $this->getAttach($message['id']);
             $attached = array_map(create_function('$a', 'return $a["fid"];'), $attached);
         }
         if (!$message['filter_file']) {
             //Нет файла: отрабатываем по фильтрам
             $sql_emp_recipient = $this->getSQLFilterEmployer($message);
             $sql_frl_recipient = $this->getSQLFilterFreelancer($message);
             // Обрабатываем фильтры, создаем запрос для выборки
             if ($message['filter_frl'] == 0 && $message['filter_emp'] == 0) {
                 $sql = $sql_emp_recipient . " UNION " . $sql_frl_recipient;
             } else {
                 if ($message['filter_frl'] > 0 && $message['filter_emp'] > 0) {
                     $sql = $sql_emp_recipient . " UNION " . $sql_frl_recipient;
                 } else {
                     if ($message['filter_frl'] > 0) {
                         $sql = $sql_frl_recipient;
                     } else {
                         if ($message['filter_emp'] > 0) {
                             $sql = $sql_emp_recipient;
                         }
                     }
                 }
             }
         }
         // Отправка личным сообщением
         if ($message['type_sending'][0] == 1) {
             $this->log->write("Initialization sending to personal messages\n");
             $msg_attached = "'{}'";
             if (count($attached) > 0) {
                 $msg_attached = "'{" . implode(", ", $attached) . "}'";
             }
             $msgid = $PLDB->val("SELECT masssend({$message['user_id']}, '{$message['message']}', {$msg_attached}, '')");
         }
         // Отправка по почте
         if ($message['type_sending'][1] == 1) {
             $this->log->write("Initialization sending to email\n");
             $mail = new smtp();
             $mail->prepare = true;
             $mail->subject = $message['subject'];
             $mail->message = $this->getMailContent($message['message']);
             $mail->recipient = '';
             $spamid = $mail->send('text/html', $attached);
             $mail->recipient = array();
         }
         // Если ничего не выбрано отправляем обоими способами
         if ($message['type_sending'][0] == 0 && $message['type_sending'][1] == 0) {
             $this->log->write("Initialization sending to personal messages\n");
             $msg_attached = "'{}'";
             if (count($attached) > 0) {
                 $msg_attached = "'{" . implode(", ", $attached) . "}'";
             }
             $msgid = $PLDB->val("SELECT masssend({$message['user_id']}, '{$message['message']}', {$msg_attached}, '')");
             // ------------------------------ //
             $this->log->write("Initialization sending to email\n");
             $mail = new smtp();
             $mail->prepare = true;
             $mail->subject = $message['subject'];
             $mail->message = $this->getMailContent($message['message']);
             $mail->recipient = '';
             $spamid = $mail->send('text/html', $attached);
             $mail->recipient = array();
         }
         $i = 0;
         $cnt_emp = 0;
         $cnt_frl = 0;
         if ($message['filter_file']) {
             while ($user = $this->parseExtraList($message['filter_file'], $i)) {
                 $cnt_frl += count($user);
                 $users = array();
                 foreach ($user as $u) {
                     $users[] = (int) $u['uid'];
                 }
                 if ($msgid) {
                     $PLDB->query("SELECT masssend_bind(?, ?, ?a)", $msgid, $message['user_id'], $users);
                 }
                 if ($spamid) {
                     $mail->recipient = array_map(array("mailer", "array2send"), $user);
                     $mail->bind($spamid);
                     $mail->recipient = array();
                 }
                 $i = $i + self::MAX_SEND_USERS;
             }
             $this->log->write("Complite binding users (parsed users = {$cnt_frl})\n");
         } else {
             while ($users = $DB->col($sql . " LIMIT " . self::MAX_SEND_USERS . " OFFSET ?", $i)) {
                 $user = $DB->rows("SELECT uid, login, uname, usurname, role, email FROM users WHERE uid IN (?l)", $users);
                 $emp = array_filter($user, create_function('$a', 'return (substr($a["role"], 0, 1) == 1);'));
                 $frl = array_filter($user, create_function('$a', 'return !(substr($a["role"], 0, 1) == 1);'));
                 $cnt_emp += count($emp);
                 $cnt_frl += count($frl);
                 if ($msgid) {
                     $PLDB->query("SELECT masssend_bind(?, ?, ?a)", $msgid, $message['user_id'], $users);
                 }
                 if ($spamid) {
                     $mail->recipient = array_map(array("mailer", "array2send"), $user);
                     $mail->bind($spamid);
                     $mail->recipient = array();
                 }
                 $i = $i + self::MAX_SEND_USERS;
             }
             $this->log->write("Complite binding users (employer = {$cnt_emp}, freelancer = {$cnt_frl})\n");
         }
         $PLDB->query("SELECT masssend_commit(?, ?)", $msgid, $message['user_id']);
         // Обновляем данные рассылки
         $this->update(array("status_sending" => 1, "status_message" => 1, "real_date_sending" => "NOW()", "msgid" => (int) $msgid, "spamid" => (int) $spamid, "count_rec_frl" => (int) $cnt_frl, "count_rec_emp" => (int) $cnt_emp), $message['id']);
         if ($message['type_regular'] > 1) {
             $this->updateRegularDate($message['type_regular'], $message['id']);
         }
         unset($mail, $msgid, $spamid);
         $this->log->write("\n-----------------------------------------------------------------------\n");
     }
     $this->log->write("Complite sending messages\n");
 }
示例#3
0
Зайдите, пожалуйста, на страницу <a href="https://www.fl.ru/remind/">восстановления пароля</a> и запросите ссылку для изменения пароля.
<br/><br/>
Также, для повышения безопасности вашего аккаунта, привяжите свой аккаунт к соцсети <br/>
и воспользуйтесь двухэтапной аутентификацией - http://feedback.fl.ru/topic/683170-dvuhetapnaya-autentifikatsiya-cherez-sotsseti/
<br/><br/>
С уважением, <br/>
команда <a href="https://www.fl.ru">FL.ru</a>
';
//------------------------------------------------------------------------------
$mail = new smtp();
$mail->subject = $subject;
$mail->message = $message;
$mail->recipient = '';
$spamid = $mail->send('text/html');
if (!$spamid) {
    die("Failed!\n");
}
$mail->recipient = array();
$users = $DB->rows('
    SELECT DISTINCT uid, uname, usurname, login, email 
    FROM users WHERE uid IN(?l)   
', $uids);
if (!$users) {
    die('Users not found.');
}
foreach ($users as $user) {
    $mail->recipient[] = array('email' => $user['uname'] . ' ' . $user['usurname'] . ' [' . $user['login'] . '] <' . $user['email'] . '>', 'extra' => array('USER_NAME' => $user['uname'], 'USER_SURNAME' => $user['usurname'], 'USER_LOGIN' => $user['login']));
}
$mail->bind($spamid, true);
$cnt = count($users);
echo "OK. Total: {$cnt} users\n";
示例#4
0
//$cnt = $mail->NewProj2($users);
//var_dump($cnt);
//print_r($GLOBALS['TESTERS_MAIL']);
//exit;
$mail = new smtp();
$mail->subject = 'Тема письма - проверка рассылки';
$mail->message = 'Это тело письма';
$mail->recipient = '';
$spamid = $mail->send('text/html');
if (!$spamid) {
    die("Failed!\n");
}
$mail->recipient = array();
$rows[] = array('uname' => 'Алексей', 'usurname' => 'Казаков', 'email' => '*****@*****.**');
$rows[] = array('uname' => 'Алексей', 'usurname' => 'Казаков', 'email' => '*****@*****.**');
$rows[] = array('uname' => 'Алексей', 'usurname' => 'Казаков', 'email' => '*****@*****.**');
$rows[] = array('uname' => 'Алексей', 'usurname' => 'Казаков', 'email' => '*****@*****.**');
$rows[] = array('uname' => 'Алексей', 'usurname' => 'Казаков', 'email' => '*****@*****.**');
/*
$rows[] = array(
    'uname'     => 'Алексей',
    'usurname'  => 'Казаков',
    'email'     => '*****@*****.**'
);
*/
foreach ($rows as $row) {
    $mail->recipient[] = array('email' => $row['email']);
}
$res = $mail->bind($spamid);
var_dump($res);
exit;