예제 #1
0
 /**
  * Send a message.
  *
  * @return void
  */
 protected function _execute(array $params)
 {
     $config = Kohana::$config->load('mailqueue');
     $transport_class = $config->get('transport.class', 'mail');
     $transport_classname = 'Swift_' . ucfirst($transport_class) . 'Transport';
     $transport = $transport_classname::newInstance();
     $mq = new MailQueue();
     $mq->setTransport($transport);
     $mq->send($params['count']);
 }
예제 #2
0
 public function testAdvancedSearch()
 {
     // Create a new model containing search filter info
     $model = new MailQueue('search');
     $model->isSimpleSearch = false;
     $model->recipient = 'test@localhost';
     // Search - this will return a data provider
     $dataProvider = $model->search();
     // Expect one payment found
     $this->assertTrue(count($dataProvider->data) == 1);
 }
예제 #3
0
 /**
  * This is just for the demo sending.
  */
 public function action_send()
 {
     $message = new Swift_Message();
     $message->addTo($this->request->post('to'));
     $message->addFrom($this->request->post('from'));
     $message->setSubject($this->request->post('subject'));
     $message->setBody($this->request->post('message'));
     $mq = new MailQueue();
     $mq->add($message);
     $this->redirect('mailqueue/demo');
 }
예제 #4
0
파일: Helper.php 프로젝트: rj28/test
 public static function logException(Exception $e, $mail = true)
 {
     $di = DI::getDefault();
     if ($di->has('request')) {
         /** @var \Phalcon\Http\Request $request */
         $request = $di->getShared('request');
         $requestUri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '<!undefined>';
         //$queryString = isset($_SERVER['QUERY_STRING']) ? ($_SERVER['QUERY_STRING'] ? '?' . $_SERVER['QUERY_STRING'] : '') : '?<!undefined>';
         $message = date('Y-m-d H:i:s') . ' ' . get_class($e) . ': ' . $e->getMessage() . "\n" . 'UserAgent: ' . $request->getUserAgent() . "\n" . 'HTTP Referrer: ' . urldecode($request->getHTTPReferer()) . "\n" . $request->getClientAddress() . " URL: " . $request->getScheme() . '://' . $request->getHttpHost() . urldecode($requestUri) . "\n" . $e->getTraceAsString() . "\n";
     } else {
         $message = date('Y-m-d H:i:s') . ' ' . $e->getMessage() . "\n" . "There is no request object\n" . $e->getTraceAsString();
     }
     if (Config::instance()->mail_exceptions && $mail) {
         switch (true) {
             //			case $e instanceof PageNotFound:
             //			case $e instanceof Phalcon\Mvc\Dispatcher\Exception:
             case $e instanceof DoNotMail:
                 break;
             default:
                 \MailQueue::push2admin('Exception', $message);
                 break;
         }
     }
     \Logger::messages()->error($message);
 }
예제 #5
0
파일: bootstrap.php 프로젝트: rj28/executer
function logException(Exception $e, $mail = true)
{
    Logger::messages()->exception($e);
    if (Config::instance()->production) {
        if (Phalcon\DI::getDefault()->has('request')) {
            /** @var \Phalcon\Http\Request $request */
            $request = Phalcon\DI::getDefault()->getShared('request');
            $message = sprintf("%s %s: %s\n" . "UserAgent: %s\n" . "HTTP Referer: %s\n" . "%s URL: %s://%s\n" . "LoggedUser: %s\n" . "%s", date('Y-m-d H:i:s'), get_class($e), $e->getMessage(), $request->getUserAgent(), urldecode($request->getHTTPReferer()), $request->getClientAddress(), $request->getScheme(), $request->getHttpHost() . urldecode(isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '<!undefined>'), $e->getTraceAsString());
        } else {
            $message = date('Y-m-d H:i:s') . ' ' . $e->getMessage() . "\n" . "There is no request object\n" . $e->getTraceAsString();
        }
        switch (true) {
            //			case $e instanceof PageNotFound:
            //			case $e instanceof Phalcon\Mvc\Dispatcher\Exception:
            //				break;
            default:
                if (Config::instance()->mail_exceptions && $mail) {
                    MailQueue::push2admin('Exception', $message);
                }
                break;
        }
    } else {
        throw $e;
    }
}
예제 #6
0
 public function addMailQueue($message, $from_email, $from_name, $to_email, $subject)
 {
     $queue = new MailQueue();
     $queue->from_email = $from_email;
     $queue->from_name = $from_name;
     $queue->to_email = $to_email;
     $queue->subject = $subject;
     $queue->message = $message;
     $queue->date_published = time();
     $queue->attempts = 0;
     $queue->max_attempts = 5;
     $queue->success = 0;
     if ($queue->save(FALSE)) {
         return TRUE;
     }
     return FALSE;
 }
    public function sendIssue($issue, $to, $message)
    {
        $routing = sfContext::getInstance()->getRouting();
        $issue_url = $routing->generate('issues_show', $issue, true);
        $mail = new MailQueue();
        $mail->setSubject("Amaranto issue #{$issue->id}: {$issue->title}");
        $mail->addTo($to);
        $mail->setBody(<<<EOF
{$message}:

Id: {$issue->id}
Title: {$issue->title}
Project: {$issue->Project}
Priority: {$issue->Priority}
Opened by: {$issue->OpenedBy}

You can see this issue at: {$issue_url}

EOF
);
        $mail->save();
    }
예제 #8
0
 /**
  * Add a message to the queue, and 'send' it.
  * The queue length should decrease.
  */
 public function test_send()
 {
     $message1 = Swift_Message::newInstance()->setSubject('First Message');
     $message2 = Swift_Message::newInstance()->setSubject('Second Message');
     $mq = new MailQueue();
     $mq->add($message1);
     $mq->add($message2);
     $this->assertCount(2, $mq->getPending());
     $mq->send(1);
     $this->assertCount(1, $mq->getPending());
 }
예제 #9
0
 public function actionSendMailQueue()
 {
     $criteria = new CDbCriteria(array('condition' => 'success=:success AND attempts < max_attempts', 'params' => array(':success' => 0)));
     $queueList = MailQueue::model()->findAll($criteria);
     foreach ($queueList as $queueItem) {
         $result = EmailHelper::sendEmail($queueItem->subject, $queueItem->to_email, $queueItem->message, $queueItem->from_email, $queueItem->from_name);
         if ($result) {
             $queueItem->attempts = $queueItem->attempts + 1;
             $queueItem->success = 1;
             $queueItem->last_attempt = time();
             $queueItem->date_sent = time();
             $queueItem->save(FALSE);
         } else {
             $queueItem->attempts = $queueItem->attempts + 1;
             $queueItem->last_attempt = time();
             $queueItem->save(FALSE);
         }
     }
 }
예제 #10
0
 public function run($args)
 {
     Yii::log("Entering the method run", "info");
     if (0 != $this->checkDaemonStatus()) {
         return 1;
     }
     // Delete old operations
     Operation::deleteOldOperations();
     // Look for started debug info deletion operations,check their statuses
     // and finalize completed operations.
     $this->checkDebugInfoDeletionOperations();
     // Delete debug info files marked for deletion
     $this->deletePendingDebugInfoFiles();
     // Look for started debug info import operations, check their statuses
     // and finalize completed operations.
     $this->checkDebugInfoProcessingOperations();
     // Import new debug info files uploaded recently.
     $this->processNewDebugInfoFiles();
     // Look for started crash report processing operations, check their statuses
     // and finalize completed operations.
     $this->checkCrashReportProcessingOperations();
     // Process new crash report files uploaded recently.
     $this->processNewCrashReportFiles();
     // Send pending mail messages.
     MailQueue::sendMail();
     // Perform batch import of crash report files and PDB files
     $importDir = Yii::app()->getBasePath() . "/import";
     $batchImporter = new BatchImporter();
     $importedCrashReportCount = 0;
     $importedDebugInfoCount = 0;
     $batchImporter->importFiles($importDir, $importedCrashReportCount, $importedDebugInfoCount);
     // Delete old temp files
     $this->deleteOldTempFiles();
     // Success
     Yii::log("Leaving the method run", "info");
     return 0;
 }
예제 #11
0
파일: Provider.php 프로젝트: huynt57/soyba
 public function add($post)
 {
     $model = new Provider();
     $model->setAttributes($post);
     $model->active = 0;
     //MailQueue::model()->add();
     if ($model->save(FALSE)) {
         MailQueue::model()->addMailQueue('Có một đơn vị cung cấp dịch vụ y tế đã đăng ký tới Meboo', '*****@*****.**', 'meboo admin', '*****@*****.**', 'Có một đơn đặt hàng mới dịch vụ medlatec');
         return TRUE;
     }
     return FALSE;
 }
예제 #12
0
파일: User.php 프로젝트: xyzz/CrashFix
 /**
  *  This method adds an email to pending mail queue. The email contains
  *  new user account activation link.
  *  @return boolean True on success.
  */
 public function sendEmailWithAccountActivationLink()
 {
     // Send an E-mail with account activation link
     $emailFrom = "no-reply@" . Yii::app()->request->serverName;
     $emailSubject = "[CrashFix] Account Activation";
     $emailText = "This message has been sent to you, because someone has created\r\n";
     $emailText .= "a CrashFix account for you.\r\n\r\n";
     $emailText .= "IMPORTANT: If you did not request to create a CrashFix account for you,\r\n";
     $emailText .= "tell your administrator about this letter.\r\n\r";
     $emailText .= "If you did request to create an account for you, then please follow\r\n";
     $emailText .= "this link to login into your CrashFix account and enter your new password:\r\n";
     $emailText .= Yii::app()->createAbsoluteUrl('site/login', array('prt' => $this->pwd_reset_token));
     $emailText .= "\r\n";
     $headers = "From: {$emailFrom}\r\nReply-To: {$emailFrom}";
     // Add an email to mail queue.
     return MailQueue::addMail($this->email, $emailSubject, $emailText);
 }
예제 #13
0
파일: Mail.php 프로젝트: anas/feedstore
 public function cron()
 {
     require '../../core/PEAR/Mail.php';
     require 'Mail/mime.php';
     $queue = MailQueue::getAllMailQueues(self::SEND_PER_CRON_JOB);
     $this->smarty->assign('site', 'http://192.168.6.109');
     foreach ($queue as $q) {
         $content = new MailSendOut($q->getSendOut());
         $user = new MailUser($q->getUser());
         $crlf = "\n";
         $hdrs = array('From' => $content->getFromName() . '<' . $content->getFromAddress() . '>', 'Subject' => $content->getSubject(), 'To' => $user->getFirstName() . ' ' . $user->getLastName() . '<' . $user->getEmail() . '>', 'Date' => date('r', strtotime($content->getTimestamp())));
         $this->smarty->assign('content', $content);
         $this->smarty->assign('user', $user);
         $body = $this->smarty->fetch('admin/shell.tpl');
         $mime = new Mail_mime($crlf);
         $mime->setHTMLBody($body);
         //do not ever try to call these lines in reverse order
         $body = $mime->get();
         $hdrs = $mime->headers($hdrs);
         $mail =& Mail::factory('sendmail');
         $mail->send($user->getEmail(), $hdrs, $body);
         $log = new MailDeliveryLog();
         $log->setUser($user->getId());
         $log->setSendOut($content->getId());
         $log->setQueue($q->getId());
         $log->save();
         $q->delete();
     }
 }
예제 #14
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param string the username of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = MailQueue::model()->findByAttributes(array('id' => $id));
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
예제 #15
0
 public function actionActivate()
 {
     $request = Yii::app()->request;
     try {
         $token = StringHelper::filterString($request->getQuery('token'));
         if ($token != '') {
             $check = Provider::model()->findByAttributes(array('token' => $token));
             if ($check) {
                 $password = StringHelper::generateRandomString(5);
                 $check->token = '';
                 $check->password = md5($password);
                 $check->save('FALSE');
                 $subject = 'Mật khẩu tài khoản provider Meboo của bạn';
                 $to_email = $check->email;
                 $from_email = '*****@*****.**';
                 $from_name = 'Hỗ trợ Meboo';
                 $message = 'Mật khẩu tài khoản Meboo Provider của bạn: ' . $password;
                 MailQueue::model()->addMailQueue($message, $from_email, $from_name, $to_email, $subject);
                 MailQueue::model()->addMailQueue('Có provider mới', $from_email, $from_name, '*****@*****.**', 'Có provider mới');
                 Yii::app()->user->setFlash('success', 'Vui lòng kiểm tra email để lấy mật khẩu đăng nhập');
                 $this->redirect(Yii::app()->createUrl('user/login'));
             } else {
                 Yii::app()->user->setFlash('error', 'Token đã hết hạn !');
                 $this->redirect(Yii::app()->createUrl('user/login'));
             }
         } else {
             Yii::app()->user->setFlash('error', 'Token không tồn tại');
             $this->redirect(Yii::app()->createUrl('user/login'));
         }
     } catch (Exception $ex) {
         ResponseHelper::JsonReturnError($ex->getMessage(), 'Error');
     }
 }
예제 #16
0
파일: MailQueue.php 프로젝트: xyzz/CrashFix
 /**
  * Sends pending mail messages.
  * @return void
  */
 public static function sendMail()
 {
     // Prepare search criteria
     $criteria = new CDbCriteria();
     $criteria->condition = 'status=' . self::STATUS_PENDING;
     $criteria->order = 'create_time ASC';
     $criteria->limit = 5;
     // Look for pending email items
     $pendingItems = MailQueue::model()->findAll($criteria);
     // Walk through pending items
     foreach ($pendingItems as $email) {
         // Send email
         $result = @mail($email->recipient, $email->email_subject, $email->email_body, $email->email_headers);
         if ($result == true) {
             // Succeeded
             $email->status = self::STATUS_SENT;
             $email->sent_time = time();
         } else {
             // Failed
             $email->status = self::STATUS_FAILED;
             Yii::log('Error sending email ', 'info');
         }
         // Save changes to DB
         $email->save();
     }
 }
예제 #17
0
파일: Bug.php 프로젝트: xyzz/CrashFix
 /**
  * This method sends an email to bug owner and reporter.
  * The email contains bug change information.
  * @return boolean true on success.
  */
 public function sendBugChangeNotificationEmail($bugChange)
 {
     $emailSubject = "[CrashFix] Bug #" . $bugChange->bug->id . " Has Been Changed";
     $emailText = "Bug #" . $bugChange->bug_id . " " . $bugChange->bug->summary . "\r\n";
     $emailText .= "URL: " . Yii::app()->createAbsoluteUrl('bug/view', array('id' => $bugChange->bug_id));
     $emailText .= "\r\n";
     $emailText .= "Changed by " . $bugChange->user->username . " on " . date('j F Y, G:i', $bugChange->timestamp) . "\r\n";
     $emailText .= "\r\n";
     if ($bugChange->comment != null) {
         $emailText .= "Comment has been entered:\r\n";
         $emailText .= wordwrap($bugChange->comment->text, 70) . "\r\n";
         $emailText .= "\r\n";
     }
     if ($bugChange->statuschange != null) {
         if (isset($bugChange->statuschange->status)) {
             $emailText .= "Status:" . Lookup::item('BugStatus', $bugChange->statuschange->status) . "\r\n";
             if ($bugChange->statuschange->status == Bug::STATUS_DUPLICATE) {
                 $emailText .= "Merged into bug: #" . $bugChange->statuschange->merged_into . "\r\n";
             }
         }
         if (isset($bugChange->statuschange->priority)) {
             $emailText .= "Priority: " . Lookup::item('BugPriority', $bugChange->statuschange->priority) . "\r\n";
         }
         if (isset($bugChange->statuschange->reproducability)) {
             $emailText .= "Reproducibiliity: " . Lookup::item('BugReproducability', $bugChange->statuschange->reproducability) . "\r\n";
         }
         if (isset($bugChange->statuschange->owner)) {
             $emailText .= "Owner: " . $bugChange->statuschange->owner->username . "\r\n";
         }
         $emailText .= "\r\n";
     }
     foreach ($bugChange->attachments as $attachment) {
         $emailText .= "File attached: " . $attachment->filename;
         $emailText .= "\r\n";
     }
     $emailText .= "\r\n";
     // Send an email to bug reporter
     $add1 = MailQueue::addMail($bugChange->bug->reporter->email, $emailSubject, $emailText);
     $add2 = false;
     // Send an email to bug owner
     if ($bugChange->bug->owner != null && $bugChange->bug->owner->id != $bugChange->bug->reporter->id) {
         $add2 = MailQueue::addMail($bugChange->bug->owner->email, $emailSubject, $emailText);
     }
     return $add1 && $add2;
 }
예제 #18
0
 public function add($post)
 {
     $model = new OrderMedlatec();
     $model->setAttributes($post);
     //$order->time_meet = StringHelper::dateToTime($post['time_meet']);
     //$order->time_confirm = StringHelper::dateToTime($post['time_confirm']);
     $model->created_at = time();
     $model->updated_at = time();
     $model->time_meet = time();
     $model->time_confirm = time();
     if ($model->save(FALSE)) {
         MailQueue::model()->addMailQueue('Có một đơn đặt hàng mới dịch vụ medlatec', '*****@*****.**', 'meboo admin', '*****@*****.**', 'Có một đơn đặt hàng mới dịch vụ medlatec');
         return $model->id;
     }
     return FALSE;
 }
예제 #19
0
파일: MailList.php 프로젝트: anas/feedstore
 public function queueUsers($sendout)
 {
     foreach ($this->getListUsers() as $user) {
         $itm = new MailQueue();
         $itm->setUser($user->getId());
         $itm->setSendOut($sendout->getId());
         $itm->save();
     }
 }