Example #1
0
 /**
  * Try sending e-mails in the queue.
  *
  * @return void
  * @throws CDbException
  */
 private function _sendQueueEmails()
 {
     $objMails = EmailQueue::model()->findAll("`sent_attempts` < 20 and `sent_attempts` > 0 and `to` IS NOT NULL LIMIT 10");
     foreach ($objMails as $objMail) {
         $blnResult = _xls_send_email($objMail->id, true);
         if (!$blnResult) {
             EmailQueue::model()->updateByPk($objMail->id, array('sent_attempts' => $objMail->sent_attempts + 1));
         } else {
             $objMail->delete();
         }
     }
 }
Example #2
0
 /**
  * Send any emails that are still pending
  *
  * @param $intCartid
  * @return void
  */
 public static function sendEmails($intCartid)
 {
     $objEmails = EmailQueue::model()->findAllByAttributes(array('cart_id' => $intCartid));
     Yii::log(count($objEmails) . " emails to be sent", 'info', 'application.' . __CLASS__ . "." . __FUNCTION__);
     foreach ($objEmails as $objEmail) {
         _xls_send_email($objEmail->id, true);
     }
 }
 /**
  * Send pending email.
  *
  * Emails are queued in table. This function is typically called via JavaScript
  * at the end of checkout to actually send the email. This covers us in case
  * email sending fails, we don't error on checkout.
  *
  * @return void
  */
 public function actionSendemail()
 {
     $id = Yii::app()->getRequest()->getQuery('id');
     _xls_send_email($id);
 }
 public function sendEmailTest()
 {
     $objEmail = new EmailQueue();
     $objEmail->subject = "Test email from " . _xls_get_conf('STORE_NAME');
     $orderEmail = _xls_get_conf('ORDER_FROM', '');
     $objEmail->to = empty($orderEmail) ? _xls_get_conf('EMAIL_FROM') : $orderEmail;
     $objEmail->htmlbody = "<h1>You have successfully received your test email.</h1>";
     $objEmail->save();
     $blnResult = _xls_send_email($objEmail->id, true);
     if ($blnResult) {
         Yii::app()->user->setFlash('warning', 'Test email successfully sent to ' . $objEmail->to . '.');
     } else {
         Yii::app()->user->setFlash('error', 'Error - the test email failed sending to ' . $objEmail->to . '.');
         $objEmail->delete();
     }
 }