/** * Send first 10 emails in codo_mails queue */ public function dequeue() { $qry = 'SELECT * FROM ' . PREFIX . 'codo_mail_queue WHERE mail_status=0 LIMIT 10 OFFSET 0'; $obj = $this->db->query($qry); $mails = $obj->fetchAll(); if (!count($mails)) { return; } $ids = array(); foreach ($mails as $mail) { $mailer = new \CODOF\Forum\Notification\Mail(); $mailer->to = $mail['to_address']; $mailer->subject = $mail['mail_subject']; $mailer->message = $mail['body']; $mailer->send_mail(); $ids[] = $mail['id']; } $_ids = implode(",", $ids); $qry = 'DELETE FROM ' . PREFIX . 'codo_mail_queue WHERE id IN (' . $_ids . ')'; $this->db->query($qry); }
/** * * Sends an email for confirming the user . * You must call add_signup_attempt() before calling this method * * @param type $fields array of user info from User->get() * @param type $errors */ public function send_mail($fields, &$errors) { $mail = new \CODOF\Forum\Notification\Mail(); $body = \CODOF\Util::get_opt('await_approval_message'); $sub = \CODOF\Util::get_opt('await_approval_subject'); $confirm_url = RURI . "user/confirm" . "&user="******"&token=" . $this->token; $confirm_page = RURI . "user/confirm"; $mail->curr = array("token" => $this->token, "confirm_url" => $confirm_url, "confirm_page" => $confirm_page); $mail->user = $fields; $message = $mail->replace_tokens($body); $subject = $mail->replace_tokens($sub); $to = $fields['mail']; $mail->to = $to; $mail->subject = $subject; $mail->message = $message; $mail->send_mail(); if (!$mail->sent) { $errors[] = $mail->error; } }
public function req_pass() { $errors = array(); $token = uniqid() . '&' . (time() + 3600); $mail = new \CODOF\Forum\Notification\Mail(); //update the user's password with the generated password $user = \CODOF\User\User::getByMailOrUsername($_GET['ident'], $_GET['ident']); $gen = false; if (!$user) { $errors[] = _t("User does not exist with the given username/mail"); } else { $old_token = $user->token; if ($old_token != null) { $parts = explode("&", $old_token); $expiry = (int) $parts[1]; if ($expiry > time()) { $gen = true; } } else { $gen = true; } } if (empty($errors) && $gen) { \DB::table(PREFIX . 'codo_users')->where('id', $user->id)->update(array('token' => $token)); $body = \CODOF\Util::get_opt('password_reset_message'); $sub = \CODOF\Util::get_opt('password_reset_subject'); $mail->user = array("token" => $token, "link" => RURI . 'user/reset'); $message = $mail->replace_tokens($body); $subject = $mail->replace_tokens($sub); $mail->to = $user->mail; $mail->subject = $subject; $mail->message = $message; $mail->send_mail(); if (!$mail->sent) { $errors[] = $mail->error; } } $resp = array("status" => "success", "msg" => _t("E-mail sent successfully")); if (!empty($errors)) { $resp = array("status" => "fail", "msg" => $errors); } echo json_encode($resp); }
public function sendDigest() { $smarty = \CODOF\Smarty\Single::get_instance(SYSPATH . 'CODOF/Forum/Notification/Digest/', true); $user = \CODOF\User\User::get(); $smarty->assign('site_title', \CODOF\Util::get_opt('site_title')); $smarty->assign('brand_img', \CODOF\Util::get_opt('brand_img')); $smarty->assign('username', $user->username); $date = date('Y-F-j-S', time()); list($year, $month, $day, $ordinal) = explode("-", $date); $dayInfo = array("year" => $year, "month" => $month, "day" => $day, "ordinal" => $ordinal); $smarty->assign('dayInfo', $dayInfo); $smarty->assign('statistics_img', 'http://i.imgur.com/7sBa4Ow.png'); //RAW $smarty->assign('create_new_img', 'http://i.imgur.com/E0MhBwI.png'); //RAW $notifier = new \CODOF\Forum\Notification\Notifier(); $events = $notifier->get(TRUE, 0, 'asc'); //get all unread notifications $sortedEvents = $this->sort($events); $smarty->assign('events', $sortedEvents); $smarty->assign('new_posts', $this->newPosts . " "); $smarty->assign('new_topics', $this->newTopics . " "); if (empty($events)) { $smarty->assign('nothing_new', true); } else { $smarty->assign('nothing_new', false); } $frequency = $user->prefers('notification_frequency'); $html = $smarty->fetch("{$frequency}.tpl"); $text = $smarty->fetch("{$frequency}Text.tpl"); $this->daily = $html; $this->dailyText = $text; $mailer = new \CODOF\Forum\Notification\Mail(); $mailer->setHTML($mailer->replace_tokens($this->dailyText)); $mailer->to = $user->mail; $mailer->subject = _t('Daily digest - ') . \CODOF\Util::get_opt('site_title'); $mailer->message = $this->daily; $mailer->send_mail(); }