/** * Displays the contact page */ public function actionContact() { $model = CustomPage::LoadByRequestUrl('contact-us'); $this->pageTitle = $model->PageTitle; $this->pageDescription = $model->meta_description; $this->breadcrumbs = array($model->title => $model->RequestUrl); $this->layout = "//layouts/column" . $model->column_template; $ContactForm = new ContactForm(); if (isset($_POST['ContactForm'])) { $ContactForm->attributes = $_POST['ContactForm']; if ($ContactForm->validate()) { $objEmail = new EmailQueue(); if (!Yii::app()->user->isGuest) { $objCustomer = Customer::GetCurrent(); $objEmail->customer_id = $objCustomer->id; $ContactForm->fromName = $objCustomer->mainname; $ContactForm->fromEmail = $objCustomer->email; } $strHtmlBody = $this->renderPartial('/mail/_contactform', array('model' => $ContactForm), true); $strSubject = Yii::t('email', 'Contact Us:') . $ContactForm->contactSubject; $objEmail->htmlbody = $strHtmlBody; $objEmail->subject = $strSubject; $orderEmail = _xls_get_conf('ORDER_FROM', ''); $objEmail->to = empty($orderEmail) ? _xls_get_conf('EMAIL_FROM') : $orderEmail; $objHtml = new HtmlToText(); //If we get back false, it means conversion failed which 99.9% of the time means improper HTML. $strPlain = $objHtml->convert_html_to_text($strHtmlBody); if ($strPlain !== false) { $objEmail->plainbody = $strPlain; } if (!$objEmail->save()) { Yii::log("Error creating email " . print_r($objEmail, true) . " " . print_r($objEmail->getErrors(), true), 'error', 'application.' . __CLASS__ . "." . __FUNCTION__); } Yii::app()->user->setFlash('success', Yii::t('email', 'Message sent. Thank you for contacting us. We will respond to you as soon as possible.')); //Attempt to use an AJAX call to send the email. If it doesn't work, the Download process will catch it anyway. $jsScript = "\$.ajax({url:\"" . CController::createUrl('site/sendemail', array("id" => $objEmail->id)) . "\"});"; Yii::app()->clientScript->registerScript('sendemail', $jsScript, CClientScript::POS_READY); } else { Yii::app()->user->setFlash('error', Yii::t('cart', 'Please check your form for errors.')); if (YII_DEBUG) { Yii::app()->user->setFlash('error', print_r($ContactForm->getErrors(), true)); } } } if (!Yii::app()->user->isGuest) { $objCustomer = Customer::GetCurrent(); $ContactForm->fromName = $objCustomer->mainname; $ContactForm->fromEmail = $objCustomer->email; } $this->canonicalUrl = $model->canonicalUrl; $this->render('contact', array('ContactForm' => $ContactForm, 'model' => $model)); }
public static function getInstance() { if (empty(self::$instance)) { self::$instance = new EmailQueue(); } return self::$instance; }
/** * Deletes a particular model. * If deletion is successful, the browser will be redirected to the 'admin' page. * @param integer $id the ID of the model to be deleted */ public function actionDelete($id) { $this->hasPrivilege(Acl::ACTION_DELETE); EmailQueue::model()->loadModel($id)->delete(); if (!isset($_GET['ajax'])) { $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('index')); } }
/** * For subscribers of this message topic, send out an alert to them given this new message * @return void */ public function SendAlerts() { switch ($this->TopicLink->TopicLinkTypeId) { case TopicLinkType::Forum: $strLink = sprintf('http://www.qcodo.com/forums/forum.php/%s/%s/lastpage', $this->TopicLink->ForumId, $this->TopicId); break; case TopicLinkType::Issue: $strLink = sprintf('http://www.qcodo.com/issues/view.php/%s/lastpage', $this->TopicLink->IssueId); break; case TopicLinkType::WikiItem: $strLink = sprintf('http://www.qcodo.com%s?lastpage', $this->TopicLink->WikiItem->UrlPath); break; case TopicLinkType::Package: $strLink = sprintf('http://www.qcodo.com/qpm/package.php/%s/lastpage', $this->TopicLink->Package->Token); break; default: throw new Exception('Unhandled TopicLinkType: ' . $this->TopicLink->TopicLinkTypeId); } $strDisplayName = $this->Person ? $this->Person->DisplayName : 'Qcodo System Message'; $strBody = "QCODO MESSAGE POSTED\r\n"; $strBody .= sprintf("Topic: %s\r\n", $this->Topic->Name); $strBody .= sprintf("Posted By: %s\r\n", $strDisplayName); $strBody .= sprintf("Posted On: %s\r\n", $this->PostDate->__toString('DDD MMM D YYYY, h:mm zz')); $strBody .= sprintf("(to view this topic in its entirety, please go to %s)\r\n\r\n\r\n", $strLink); $strBody .= trim($this->Message); $strBody .= "\r\n\r\n------------------------------------------------------\r\nYou are receiving this message because you have opted-in for email notifications on this topic. "; $strBody .= "If you wish to no longer be notified for this topic, please go to "; $strBody .= $strLink; $strBody .= ' and click on "Email Notification". If the link does not show up, you will need first "Log In".'; $strHtml = '<style type="text/css">'; $strHtml .= 'pre { background-color: #ddddff; padding: 10px; margin-left: 20px; font-family: "Lucida Console", "Courier New", "Courier", "monospaced"; font-size: 11px; line-height: 13px; overflow: auto; }'; $strHtml .= '</style>'; $strHtml .= sprintf('<span style="font: 12px %s;">', QFontFamily::Verdana); $strHtml .= '<span style="font-size: 14px;"><strong><a href="http://www.qcodo.com/">Qcodo</a> Message Posted</strong></span><br/>'; $strHtml .= sprintf('<strong>Topic: </strong>%s<br/>', $this->Topic->Name); $strHtml .= sprintf('<strong>Posted By: </strong>%s<br/>', $strDisplayName); $strHtml .= sprintf('<strong>Posted On: </strong>%s<br/>', $this->PostDate->__toString('DDD MMM D YYYY, h:mm zz')); $strHtml .= sprintf('(to view this post in its entirety, please go to <a href="%s">%s</a>)<br/><br/><br/>', $strLink, $strLink); $strHtml .= $this->CompiledHtml; $strHtml .= '<br/><br/><hr/><br/><span style="font-size: 10px;">You are receiving this message because you have opted-in for email notifications on this forum topic. '; $strHtml .= 'If you wish to no longer be notified for this topic, please go to '; $strHtml .= sprintf('<a href="%s">%s</a>', $strLink, $strLink); $strHtml .= ' and click on "<strong>Email Notification</strong>". If the link does not show up, you will need first "<strong>Log In</strong>".'; $strHtml .= '</span></span>'; $strSubject = '[Qcodo] Re: ' . $this->Topic->Name; foreach ($this->Topic->GetPersonAsEmailArray() as $objEmailPerson) { if ($objEmailPerson->Id != $this->PersonId) { $objEmailQueue = new EmailQueue(); $objEmailQueue->ToAddress = sprintf('%s %s <%s>', $objEmailPerson->FirstName, $objEmailPerson->LastName, $objEmailPerson->Email); $objEmailQueue->FromAddress = QCODO_EMAILER; $objEmailQueue->Subject = $strSubject; $objEmailQueue->Body = $strBody; $objEmailQueue->Html = $strHtml; $objEmailQueue->Save(); } } }
public static function sendEmail($jobId) { $model = EmailQueue::model()->findByPk($jobId); if ($model && $model->sent) { return false; } else { // Send Email Here } }
/** * 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(); } } }
public function testWhetherTriggeringDeliveryResultsInEmailsBeingEnqueued() { global $wpdb; $this->assertEquals(0, EmailQueue::getInstance()->getNumberOfPendingEmails()); $this->broadcast->deliver(); $this->assertEquals($this->numberOfSubscribers, EmailQueue::getInstance()->getNumberOfPendingEmails()); //TODO: Change the following to use the EmailQueue's API after it is written. For now hitting the database directly $getRecipientsOfAllEmailsQuery = sprintf("SELECT sid FROM %swpr_queue", $wpdb->prefix); $recipientList = $wpdb->get_col($getRecipientsOfAllEmailsQuery); $difference = array_diff($recipientList, $this->sid_array); $this->assertEquals(0, count($difference)); }
public function actionSend($frequency = 55) { $endTime = time() + $frequency; // Check if a previous job has been running for the past 10 minutes. if (!DaemonUtils::checkForSync('EMAIL')) { DaemonUtils::closeJobForSync('EMAIL'); die; } $job = DaemonUtils::addJob('EMAIL'); try { $count = 0; while (($emails = EmailQueue::model()->findAll('sent=:sent', array(':sent' => '0'))) && !empty($emails) && time() < $endTime) { foreach ($emails as $email) { if (time() < $endTime) { if (!$email->sent) { $result = EmailApi::sendSmtpEmail($email); if ($result == 1) { $email->sent = 1; } else { $email->attempts++; } $email->save(); $count++; } } else { break; } } } /*while(!empty($emails) && time()<$endTime){ $result = EmailApi::sendSmtpEmails($emails); }*/ $message = "{$count} email(s) were processed."; // $message = count($emails) . " email(s) were processed."; DaemonUtils::endJob($job, $message); } catch (Exception $e) { $message = $e->getMessage(); DaemonUtils::endJob($job, $message, 'ERROR'); } }
public function createErrorEmail($ResultDescription) { //For certain errors, send the admin email if (stripos($ResultDescription, "contradicts information") !== false) { //Send email $objEmail = new EmailQueue(); $objEmail->htmlbody = "Amazon Error: " . $ResultDescription; $objEmail->subject = "Amazon Error"; $orderEmail = _xls_get_conf('ORDER_FROM', ''); $objEmail->to = empty($orderEmail) ? _xls_get_conf('EMAIL_FROM') : $orderEmail; Yii::log($objEmail->htmlbody, 'error', 'application.' . __CLASS__ . "." . __FUNCTION__); if (!$objEmail->save()) { Yii::log("Error saving Email " . print_r($objEmail->getErrors(), true), 'error', 'application.' . __CLASS__ . "." . __FUNCTION__); } } }
<?php QEmailServer::$SmtpServer = SMTP_SERVER; QEmailServer::$OriginatingServerIp = SMTP_EHLO; QEmailServer::$TestMode = SMTP_TEST_MODE; $objEmailQueue = EmailQueue::QueryArray(QQ::IsNull(QQN::EmailQueue()->ErrorFlag), QQ::Clause(QQ::OrderBy(QQN::EmailQueue()->HighPriorityFlag, false), QQ::LimitInfo(50))); foreach ($objEmailQueue as $objEmail) { $objEmail->Send(); }
/** * Static Helper Method to Create using PK arguments * You must pass in the PK arguments on an object to load, or leave it blank to create a new one. * If you want to load via QueryString or PathInfo, use the CreateFromQueryString or CreateFromPathInfo * static helper methods. Finally, specify a CreateType to define whether or not we are only allowed to * edit, or if we are also allowed to create a new one, etc. * * @param mixed $objParentObject QForm or QPanel which will be using this EmailQueueMetaControl * @param integer $intId primary key value * @param QMetaControlCreateType $intCreateType rules governing EmailQueue object creation - defaults to CreateOrEdit * @return EmailQueueMetaControl */ public static function Create($objParentObject, $intId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit) { // Attempt to Load from PK Arguments if (strlen($intId)) { $objEmailQueue = EmailQueue::Load($intId); // EmailQueue was found -- return it! if ($objEmailQueue) { return new EmailQueueMetaControl($objParentObject, $objEmailQueue); } else { if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound) { throw new QCallerException('Could not find a EmailQueue object with PK arguments: ' . $intId); } } // If EditOnly is specified, throw an exception } else { if ($intCreateType == QMetaControlCreateType::EditOnly) { throw new QCallerException('No PK arguments specified'); } } // If we are here, then we need to create a new record return new EmailQueueMetaControl($objParentObject, new EmailQueue()); }
/** * Default / simple DataBinder for this Meta DataGrid. This can easily be overridden * by calling SetDataBinder() on this DataGrid with another DataBinder of your choice. * * If a paginator is set on this DataBinder, it will use it. If not, then no pagination will be used. * It will also perform any sorting (if applicable). */ public function MetaDataBinder() { // Remember! We need to first set the TotalItemCount, which will affect the calcuation of LimitClause below if ($this->Paginator) { $this->TotalItemCount = EmailQueue::CountAll(); } // Setup the $objClauses Array $objClauses = array(); // If a column is selected to be sorted, and if that column has a OrderByClause set on it, then let's add // the OrderByClause to the $objClauses array if ($objClause = $this->OrderByClause) { array_push($objClauses, $objClause); } // Add the LimitClause information, as well if ($objClause = $this->LimitClause) { array_push($objClauses, $objClause); } // Set the DataSource to be a Query result from EmailQueue, given the clauses above $this->DataSource = EmailQueue::LoadAll($objClauses); }
public function executeEmailBulkQueue(sfWebRequest $request) { $subject = $request->getParameter('subject'); $to = $request->getParameter('recipients'); $sender_email = $request->getParameter('sender_email'); $sender_name = $request->getParameter('sender_name'); $message = $request->getParameter('message'); $send_date = $request->getParameter('send_date'); $priority = $request->getParameter('priority'); $errors = array(); // validate recievers if (empty($to)) { $errors['email'][0] = 'please specify email address'; } else { $recievers = explode(',', $to); $pat = '/^([^@\\s]+)@((?:[-a-z0-9]+\\.)+[a-z]{2,})$/i'; $full_pat = '/^([- a-z0-9]+)\\<(([^@\\s]+)@((?:[-a-z0-9]+\\.)+[a-z]{2,}))\\>$/i'; $emails = array(); foreach ($recievers as $reciever) { $reciever = trim($reciever); if (empty($reciever)) { continue; } if (preg_match($full_pat, $reciever, $matches)) { $emails[$matches[2]] = $matches[1]; } elseif (preg_match($pat, $reciever, $matches)) { $emails[$matches[0]] = ''; } else { if (!isset($errors['email'])) { $errors['email'] = array(); } $errors['email'][] = $reciever . ' is unrecognizable email'; } } } // validate subject if (empty($subject)) { $errors['subject'] = 'subject required'; } // validate send_date if (empty($send_date)) { $errors['send_date'] = 'Send date required'; } // validate sender $v_email = new sfValidatorEmail(array(), array('invalid' => 'please specify email address')); try { $sender_email = $v_email->clean($sender_email); } catch (sfValidatorError $e) { $errors['sender_email'] = $e->__toString(); } // attachments $upload_dir = sfConfig::get('sf_upload_dir') . '/' . 'bulk-email-attachments' . '/'; $files = array(); foreach ($request->getFiles() as $file) { if ($file[0]['error'] != 0) { continue; } if (move_uploaded_file($file[0]["tmp_name"], $upload_dir . $file[0]["name"])) { $files[] = array('path' => $upload_dir, 'name' => $file[0]['name']); } else { //echo '<h1>Error while uploading '.$file[0]["tmp_name"].'/'.$file[0]["name"].' to '.$upload_dir . $file[0]["name"].'</h1>'; $error['attachment'] = 'Error while uploading ' . $file[0]["name"]; } } // catch errors if ($errors) { $this->email_templates = EmailTemplatePeer::getByPersonId($this->getUser()->getId()); $this->errors = $errors; $this->recipients = $to; $this->subject = $subject; $this->sender_email = $sender_email; $this->sender_name = $sender_name; $this->message = $message; $this->priority = $priority; $this->send_date = $send_date; if (!empty($error['attachment'])) { $this->attachement_error = $error['attachment']; } $this->setTemplate('sendBulkQueue'); return sfView::SUCCESS; } $email_letter = new EmailLetter(); $email_letter->setSubject($subject); $email_letter->setSenderEmail($sender_email); $email_letter->setSenderName($sender_name); $email_letter->setBody($message); $email_letter->setAttachFilePath(serialize($files)); $email_letter->setRecipients(implode(',', array_keys($emails))); $email_letter->save(); $email_queue = new EmailQueue(); $email_queue->setPersonId($this->getUser()->getId()); $email_queue->setLetterId($email_letter->getId()); $email_queue->setRequestDate(date('Y-m-d H:i:s', time())); $email_queue->setSendDate($send_date); $email_queue->setPriority($priority); $email_queue->setSendStatus('pending'); $email_queue->save(); /* $this->getComponent('mail', 'sendBulkQueue', array( 'subject' => $subject, 'recievers' => $emails, 'sender' => array($sender_email => $sender_name), 'body' => $message, 'files' => $files, )); */ $this->getUser()->setFlash('success', 'Bulk email have successfully queued!'); $this->redirect($request->getReferer()); }
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(); } }
function execute() { EmailQueue::sendPacket(); }
function _xls_send_email($id, $hideJson = false) { $objMail = EmailQueue::model()->findByPk($id); if ($objMail instanceof EmailQueue) { $orderEmail = _xls_get_conf('ORDER_FROM', ''); $from = empty($orderEmail) ? _xls_get_conf('EMAIL_FROM') : $orderEmail; Yii::app()->setComponent('Smtpmail', null); $mail = Yii::app()->Smtpmail; //$mail->CharSet="utf-8"; $mail->Debugoutput = "error_log"; $mail->IsSMTP(); $mail->Username = Yii::app()->params['EMAIL_SMTP_USERNAME']; $mail->Password = _xls_decrypt(Yii::app()->params['EMAIL_SMTP_PASSWORD']); $mail->Mailer = 'smtp'; $mail->Port = Yii::app()->params['EMAIL_SMTP_PORT']; $SMTPSecure = ""; if (Yii::app()->params['EMAIL_SMTP_SECURITY_MODE'] == '0') { if (Yii::app()->params['EMAIL_SMTP_PORT'] == "465") { $SMTPSecure = "ssl"; } if (Yii::app()->params['EMAIL_SMTP_PORT'] == "587") { $SMTPSecure = "tls"; } } if (_xls_get_conf('EMAIL_SMTP_SECURITY_MODE') == '1') { $SMTPSecure = ""; } if (_xls_get_conf('EMAIL_SMTP_SECURITY_MODE') == '2') { $SMTPSecure = "ssl"; } if (_xls_get_conf('EMAIL_SMTP_SECURITY_MODE') == '3') { $SMTPSecure = "tls"; } $mail->SMTPAuth = true; $mail->AuthType = "LOGIN"; if (_xls_get_conf('EMAIL_SMTP_AUTH_PLAIN', '0') == '1') { $mail->AuthType = "PLAIN"; } if (empty(Yii::app()->params['EMAIL_SMTP_PASSWORD'])) { Yii::log("Password for SMTP blank, turning off SMTP Authentication", 'info', 'application.' . __CLASS__ . "." . __FUNCTION__); $mail->SMTPAuth = false; $mail->Username = ''; $mail->Password = ''; } $mail->SMTPDebug = 1; $mail->SMTPSecure = $SMTPSecure; $mail->Host = Yii::app()->params['EMAIL_SMTP_SERVER']; $mail->SetFrom($from, Yii::app()->params['STORE_NAME']); $mail->Subject = $objMail->subject; $mail->ClearAllRecipients(); $mail->AddAddress($objMail->to); if (!empty(Yii::app()->params['EMAIL_BCC'])) { if ($objMail->to != Yii::app()->params['EMAIL_BCC'] && $objMail->to == $from) { $mail->AddCC(Yii::app()->params['EMAIL_BCC']); } } $mail->MsgHTML($objMail->htmlbody); $blnResult = $mail->Send(); $mail->Password = '******'; //replace the real password before logging Yii::log("Contents of mail " . print_r($mail, true), 'info', 'application.' . __CLASS__ . "." . __FUNCTION__); if ($blnResult) { Yii::log("Sent email to " . $objMail->to . " successfully.", 'info', 'application.' . __CLASS__ . "." . __FUNCTION__); $objMail->delete(); Yii::log("Email removed from queue", 'info', 'application.' . __CLASS__ . "." . __FUNCTION__); if (!$hideJson) { echo json_encode("success"); } } else { $objMail->sent_attempts += 1; $objMail->save(); Yii::log("Sending email failed ID " . $id . " " . $objMail->to . " " . print_r($mail->ErrorInfo, true), 'error', 'application.' . __CLASS__ . "." . __FUNCTION__); if (!$hideJson) { echo json_encode("failure"); } } } return $blnResult; }
public function actionEmail() { if (Yii::app()->user->isGuest) { _xls_404(); } $model = new ShareForm(); if (isset($_POST['ShareForm'])) { $model->attributes = $_POST['ShareForm']; if ($model->validate()) { $strCode = $model->code; //Make sure code we've been passed is valid $objWishlist = Wishlist::model()->findByAttributes(array('gift_code' => $strCode)); if (!$objWishlist->Visible) { _xls_404(); } if (!Yii::app()->user->isGuest) { $objCustomer = Customer::model()->findByPk(Yii::app()->user->Id); $model->fromEmail = $objCustomer->email; $model->fromName = $objCustomer->fullname; } $strHtmlBody = $this->renderPartial('/mail/_cart', array('model' => $model), true); $strSubject = _xls_format_email_subject('EMAIL_SUBJECT_WISHLIST', $objWishlist->customer->fullname, null); $objEmail = new EmailQueue(); $objEmail->customer_id = $objWishlist->customer_id; $objEmail->htmlbody = $strHtmlBody; $objEmail->subject = $strSubject; $objEmail->to = $model->toEmail; $objHtml = new HtmlToText(); //If we get back false, it means conversion failed which 99.9% of the time means improper HTML. $strPlain = $objHtml->convert_html_to_text($strHtmlBody); if ($strPlain !== false) { $objEmail->plainbody = $strPlain; } $objEmail->save(); $response_array = array('status' => "success", 'message' => Yii::t('wishlist', 'Your wish list has been sent'), 'url' => CController::createUrl('site/sendemail', array("id" => $objEmail->id)), 'reload' => true); } else { $response_array['status'] = 'error'; $response_array['errormsg'] = _xls_convert_errors($model->getErrors()); } echo json_encode($response_array); } }
/** * Adds an object to the instance pool. * * Propel keeps cached copies of objects in an instance pool when they are retrieved * from the database. In some cases -- especially when you override doSelect*() * methods in your stub classes -- you may need to explicitly add objects * to the cache in order to ensure that the same objects are always returned by doSelect*() * and retrieveByPK*() calls. * * @param EmailQueue $value A EmailQueue object. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ public static function addInstanceToPool(EmailQueue $obj, $key = null) { if (Propel::isInstancePoolingEnabled()) { if ($key === null) { $key = (string) $obj->getId(); } // if key === null self::$instances[$key] = $obj; } }
/** * Main utility method to aid with data binding. It is used by the default BindAllRows() databinder but * could and should be used by any custom databind methods that would be used for instances of this * MetaDataGrid, by simply passing in a custom QQCondition and/or QQClause. * * If a paginator is set on this DataBinder, it will use it. If not, then no pagination will be used. * It will also perform any sorting (if applicable). * * @param QQCondition $objConditions override the default condition of QQ::All() to the query, itself * @param QQClause[] $objOptionalClauses additional optional QQClause object or array of QQClause objects for the query * @return void */ public function MetaDataBinder(QQCondition $objCondition = null, $objOptionalClauses = null) { // Setup input parameters to default values if none passed in if (!$objCondition) { $objCondition = QQ::All(); } $objClauses = $objOptionalClauses ? $objOptionalClauses : array(); // We need to first set the TotalItemCount, which will affect the calcuation of LimitClause below if ($this->Paginator) { $this->TotalItemCount = EmailQueue::QueryCount($objCondition, $objClauses); } // If a column is selected to be sorted, and if that column has a OrderByClause set on it, then let's add // the OrderByClause to the $objClauses array if ($objClause = $this->OrderByClause) { array_push($objClauses, $objClause); } // Add the LimitClause information, as well if ($objClause = $this->LimitClause) { array_push($objClauses, $objClause); } // Set the DataSource to be a Query result from EmailQueue, given the clauses above $this->DataSource = EmailQueue::QueryArray($objCondition, $objClauses); }
public function actionForgotpassword() { $model = new LoginForm(); if (isset($_POST['LoginForm'])) { Yii::log(print_r($_POST['LoginForm']['email'] . ": Requested a Password Reset Link", true), 'error', 'application.' . __CLASS__ . "." . __FUNCTION__); $model->attributes = $_POST['LoginForm']; if (empty($model->email)) { $response_array = array('status' => "failure", 'message' => Yii::t('global', 'Please enter your email before clicking this link.')); echo json_encode($response_array); Yii::app()->end(); } $objCustomer = Customer::model()->findByAttributes(array('record_type' => Customer::REGISTERED, 'email' => $model->email)); if ($objCustomer instanceof Customer) { if (is_null($objCustomer->password)) { $response_array = array('status' => "failure", 'message' => Yii::t('global', 'Your email address was found but only as a registered Facebook user. Log in via Facebook.')); echo json_encode($response_array); return; } if (!$objCustomer->GenerateTempPassword()) { $response_array = array('status' => "failure", 'message' => Yii::t('global', 'Could not reset password, please contact the site administrator.')); echo json_encode($response_array); return; } $strHtmlBody = $this->renderPartial('/mail/_resetpassword', array('model' => $objCustomer), true); $strSubject = Yii::t('global', 'Password reset'); $objEmail = new EmailQueue(); $objEmail->htmlbody = $strHtmlBody; $objEmail->subject = $strSubject; $objEmail->to = $objCustomer->email; $objEmail->save(); $response_array = array('status' => "success", 'message' => Yii::t('wishlist', 'Check your email for password reset link.'), 'url' => CController::createUrl('site/sendemail', array("id" => $objEmail->id)), 'reload' => true); echo json_encode($response_array); } else { $response_array = array('status' => "failure", 'message' => Yii::t('global', 'Your email address was not found in our system.')); echo json_encode($response_array); } } else { $response_array = array('status' => "failure", 'message' => Yii::t('global', 'Please enter your email before clicking this link.')); echo json_encode($response_array); } }
public static function GetSoapArrayFromArray($objArray) { if (!$objArray) { return null; } $objArrayToReturn = array(); foreach ($objArray as $objObject) { array_push($objArrayToReturn, EmailQueue::GetSoapObjectFromObject($objObject, true)); } return unserialize(serialize($objArrayToReturn)); }
/** * Using an email template, this will queue up an email into the email queue to be sent out. * @param string $strTemplateName the name of the template to use * @param string $strSubject the subject of the email * @param string $strFrom who the email is sent from * @param string $strTo who the email shout be sent to * @param string $strTokenArray the replacement token array * @param boolean $blnHighPriorityFlag whether or not this is a high priority message (to be sent before all other queued messages) * @return void */ public static function SendEmailUsingTemplate($strTemplateName, $strSubject, $strFrom, $strTo, $strTokenArray, $blnHighPriorityFlag = false) { $strContent = file_get_contents(__INCLUDES__ . '/email_templates/' . $strTemplateName . '.txt'); foreach ($strTokenArray as $strKey => $strValue) { $strContent = str_replace('%' . $strKey . '%', $strValue, $strContent); } $objEmail = new EmailQueue(); $objEmail->ToAddress = $strTo; $objEmail->FromAddress = $strFrom; $objEmail->Subject = $strSubject; $objEmail->Body = $strContent; $objEmail->HighPriorityFlag = $blnHighPriorityFlag; $objEmail->Save(); }
function GetDatabaseMonitors() { $sql = "select\n cv.ContactValue\n from\n t_objects ldo,\n t_objecttypes ldot,\n t_objects mdo,\n t_objecttypes mdot,\n t_objectxrefs ldx,\n t_objectxrefs lmx,\n t_objectxrefs mdx,\n t_objectxrefs cmx,\n t_contactprofiles cp,\n t_contactuses cu,\n t_contactvalues cv,\n t_contactvaluetypes cvt,\n t_priorities p\n where\n ldx.ChildObjectID = {$this->p_domainID} and\n ldo.ObjectID = ldx.ParentObjectID and\n ldot.ObjectTypeID = ldo.ObjectTypeID and\n ldot.ObjectTypeName = 'domain' and\n lmx.ChildObjectID = ldx.ParentObjectID and\n mdx.ChildObjectID = lmx.ParentObjectID and\n mdx.ParentObjectID = mdx.ChildObjectID and\n mdo.ObjectID = mdx.ParentObjectID and\n mdot.ObjectTypeID = mdo.ObjectTypeID and\n mdot.ObjectTypeName = 'domain' and\n cmx.ParentObjectID = mdo.ObjectID and\n cp.ObjectID = cmx.ChildObjectID and\n cp.IsInactive = 0 and\n cu.ContactUseID = cp.ContactUseID and\n cu.ContactUseName = 'database_monitoring' and\n cv.ContactValueID = cp.ContactValueID and\n cvt.ContactValueTypeID = cv.ContactValueTypeID and\n cvt.ContactValueTypeName = 'email' and\n cv.IsInactive = 0 and\n p.PriorityID = cp.PriorityID\n order by\n p.PriorityLevel"; $result = mysql_query($sql, $this->sqlMasterConnection()); $this->p_databaseMonitors = ""; while ($row = mysql_fetch_assoc($result)) { $this->p_databaseMonitors .= $row['ContactValue'] . ", "; } if (strlen($this->p_databaseMonitors)) { $this->p_databaseMonitors = substr($this->p_databaseMonitors, 0, strlen($this->p_databaseMonitors) - 2); } if (!strlen($this->p_databaseMonitors)) { $emailQueue = new EmailQueue(0, "*****@*****.**", "*****@*****.**", "iEMS at CRS, Inc.", "*****@*****.**", "CRS_ERROR: iEMS Contact Management Error", "No Database Monitor email addresses found for domain {$this->p_domainID}\n\n" . "sql=\n{$sql}", "", 0, 0, 0, "IEMS." . date("Y-m-d.His"), 0, 1); $emailQueue->Put(); } return $this->p_databaseMonitors; }
/** * 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); } }
<?php QEmailServer::$SmtpServer = SMTP_SERVER; QEmailServer::$SmtpPort = SMTP_PORT; QEmailServer::$SmtpUsername = SMTP_USERNAME; QEmailServer::$SmtpPassword = SMTP_PASSWORD; QEmailServer::$AuthLogin = true; $objEmailQueue = EmailQueue::QueryArray(QQ::IsNull(QQN::EmailQueue()->ErrorFlag), QQ::Clause(QQ::LimitInfo(50))); foreach ($objEmailQueue as $objEmail) { $objEmail->Send(); }
$userObject = new Object(); $userObject->Get($userID); $domainObject = new Object(); $domainObject->Get($domainID); $userObject = clone $_SESSION['UserObject']; $cvType = $cvTypes[$cvTypeID]->description(); $emailToAddress = $contactManager->GetDatabaseMonitors(); $emailFromAddress = "*****@*****.**"; $emailFromName = "iEMS at CRS, Inc."; $emailReplyToAddress = "*****@*****.**"; $emailSubject = "iEMS: Contact Management Updates for " . $contactProfile->object()->description(); $emailBody = "User " . $userObject->fullName() . " of " . $userObject->Domains(0)->description() . " added the " . $contactUse->description() . " " . $cvType . " contact of " . $contactValue . " for owner of " . $ownerName . " with a priority of " . $priority->level() . " to the contact profile " . $object->description() . " at " . date("H:i:s") . " on " . date("l, F j, Y") . "."; $emailAttachments = ""; $messageIdentifier = "iEMS" . "." . $userID . "." . $domainID . "." . date("Ymd.His"); //echo "emailToAddress='{$emailToAddress}'<br>\nemailBody='{$emailBody}'<br>\nmessageIdentifier='$messageIdentifier'<br>\n"; $emailQueue = new EmailQueue(0, $emailToAddress, $emailFromAddress, $emailFromName, $emailReplyToAddress, $emailSubject, $emailBody, "", 0, 0, 0, $messageIdentifier, 0, $userID); $emailQueue->Put(); print viewProfiles($userID, $domainID, null, $emailBody); } } function viewProfiles($userID, $domainID, $errorMessage = null, $alertMessage = null) { if (isset($_POST['ContactUse'])) { $contactUse = $_POST['ContactUse']; $basicProfiles = $_POST['basicProfiles']; $_SESSION['ContactUse'] = $contactUse; $_SESSION['basicProfiles'] = $basicProfiles; } else { $contactUse = $_SESSION['ContactUse']; $basicProfiles = $_SESSION['basicProfiles']; }
/** * Create an Email receipt for both the customer and the store, if needed. This goes to our emailqueue table * @param $objCart */ public static function EmailReceipts($objCart) { if (_xls_get_conf('EMAIL_SEND_CUSTOMER', 0) == 1) { $strHtmlBody = Yii::app()->controller->renderPartial('/mail/_customerreceipt', array('cart' => $objCart), true); $strSubject = _xls_format_email_subject('EMAIL_SUBJECT_CUSTOMER', $objCart->customer->first_name . ' ' . $objCart->customer->last_name, $objCart->id_str); $objEmail = new EmailQueue(); $objEmail->customer_id = $objCart->customer_id; $objEmail->htmlbody = $strHtmlBody; $objEmail->cart_id = $objCart->id; $objEmail->subject = $strSubject; $objEmail->to = $objCart->customer->email; // If we get back false, it means conversion failed which 99.9% of // the time means improper HTML. $strPlain = strip_tags($strHtmlBody); if ($strPlain !== false) { $objEmail->plainbody = $strPlain; } $objEmail->save(); } if (_xls_get_conf('EMAIL_SEND_STORE', 0) == 1) { $strHtmlBody = Yii::app()->controller->renderPartial('/mail/_customerreceipt', array('cart' => $objCart), true); $strSubject = _xls_format_email_subject('EMAIL_SUBJECT_OWNER', $objCart->customer->first_name . ' ' . $objCart->customer->last_name, $objCart->id_str); $objEmail = new EmailQueue(); $objEmail->customer_id = $objCart->customer_id; $objEmail->htmlbody = $strHtmlBody; $objEmail->cart_id = $objCart->id; $objEmail->subject = $strSubject; $orderEmail = _xls_get_conf('ORDER_FROM', ''); $objEmail->to = empty($orderEmail) ? _xls_get_conf('EMAIL_FROM') : $orderEmail; // If we get back false, it means conversion failed which 99.9% of // the time means improper HTML. $strPlain = strip_tags($strHtmlBody); if ($strPlain !== false) { $objEmail->plainbody = $strPlain; } $objEmail->save(); } }