예제 #1
0
파일: site-worker.php 프로젝트: rjha/sc
function process_mail_queue($mysqli)
{
    $sql = " select * from sc_mail_queue where flag = 0 order by id limit 50";
    $map = array();
    $rows = MySQL\Helper::fetchRows($mysqli, $sql);
    foreach ($rows as $row) {
        $email = $row["email"];
        $source = $row["source"];
        settype($source, "integer");
        $khash = md5($email . $source);
        $name = $row["name"];
        if (!in_array($khash, $map)) {
            // send mail
            // assume error
            $code = 1;
            switch ($source) {
                case AppConstants::RESET_PASSWORD_MAIL:
                    $code = WebMail::sendResetPassword($name, $email, $row["token"]);
                    \com\indigloo\sc\mysql\Mail::toggle($email);
                    array_push($map, $khash);
                    break;
                case AppConstants::NEW_ACCOUNT_MAIL:
                    $code = WebMail::newAccountMail($name, $email);
                    break;
            }
            if ($code > 0) {
                $message = sprintf("code %s - error sending mail. aborting!", $code);
                throw new Exception($message);
            }
            //mail went
            \com\indigloo\sc\mysql\Mail::toggle($email);
            array_push($map, $khash);
        }
    }
    //:loop
    //delete old mails in queue
    $sql2 = " delete from sc_mail_queue where flag = 1 and created_on < (now() - interval 1 DAY)";
    MySQL\Helper::executeSQL($mysqli, $sql2);
}
예제 #2
0
파일: Mail.php 프로젝트: rjha/sc
 function capture($emails, $message)
 {
     mysql\Mail::capture($emails, $message);
 }