/**
  * Check usage of template code in other templates
  *
  * @param   Mage_Core_Model_Email_Template $template
  * @return  boolean
  */
 public function checkCodeUsage(Mage_Core_Model_Email_Template $template)
 {
     if ($template->getTemplateActual() != 0 || is_null($template->getTemplateActual())) {
         $select = $this->_read->select()->from($this->_templateTable, new Zend_Db_Expr('COUNT(template_id)'))->where('template_id!=?', $template->getId())->where('template_code=?', $template->getTemplateCode());
         $countOfCodes = $this->_read->fetchOne($select);
         return $countOfCodes > 0;
     } else {
         return false;
     }
 }
Exemplo n.º 2
0
 /**
  * Check usage of template code in other templates
  *
  * @param Mage_Core_Model_Email_Template $template
  * @return boolean
  */
 public function checkCodeUsage(Mage_Core_Model_Email_Template $template)
 {
     if ($template->getTemplateActual() != 0 || is_null($template->getTemplateActual())) {
         $select = $this->_getReadAdapter()->select()->from($this->getMainTable(), 'COUNT(*)')->where('template_id != :template_id')->where('template_code = :template_code');
         $bind = array('template_id' => $template->getId(), 'template_code' => $template->getTemplateCode());
         $result = $this->_getReadAdapter()->fetchOne($select, $bind);
         if ($result) {
             return true;
         }
     }
     return false;
 }
Exemplo n.º 3
0
 public function getAvailableTemplates($asHash = true)
 {
     $result = array();
     $collection = Mage::getResourceModel('core/email_template_collection')->load();
     $options = $collection->toOptionArray();
     $defOptions = Mage_Core_Model_Email_Template::getDefaultTemplatesAsOptionsArray();
     // the same as + but to be sure
     foreach ($defOptions as $v) {
         $options[] = $v;
     }
     // convert to hash
     foreach ($options as $v) {
         $result[$v['value']] = $v['label'];
     }
     // sort by names alphabetically
     asort($result);
     if (!$asHash) {
         $options = array();
         foreach ($result as $k => $v) {
             $options[] = array('value' => $k, 'label' => $v);
         }
         $result = $options;
     }
     return $result;
 }
Exemplo n.º 4
0
 public function toOptionArray()
 {
     $options = Mage_Core_Model_Email_Template::getDefaultTemplatesAsOptionsArray();
     $options[0]['label'] = Mage::helper('aw_hdu3')->__('Do not send');
     $options[0]['value'] = 0;
     return array_merge($options, parent::toOptionArray());
 }
Exemplo n.º 5
0
 /**
  * Load template by configuration path. This enables html templates to include other html templates by their
  * system configuration XPATH value
  *
  * @param   string $configPath The path to the config setting that defines which global/template/email/* node
  * should be used to load the email template
  * @return   Mage_Core_Model_Email_Template
  */
 public function loadByConfigPath($configPath)
 {
     $templateId = Mage::getStoreConfig($configPath);
     if (is_numeric($templateId)) {
         // Template was overridden in admin, so load template from database
         $this->load($templateId);
     } else {
         $defaultTemplates = Mage_Core_Model_Email_Template::getDefaultTemplates();
         if (!isset($defaultTemplates[$templateId])) {
             return null;
         }
         $storeId = $this->getDesignConfig()->getStore();
         $data =& $defaultTemplates[$templateId];
         $this->setTemplateType($data['type'] == 'html' ? self::TYPE_HTML : self::TYPE_TEXT);
         $localeCode = Mage::getStoreConfig('general/locale/code', $storeId);
         $templateText = Mage::app()->getTranslator()->getTemplateFile($data['file'], 'email', $localeCode);
         $this->setTemplateText($templateText);
         $this->setId($templateId);
     }
     // Templates loaded via the {{template config_path=""}} syntax don't support the subject/vars/styles
     // comment blocks, so strip them out
     $templateText = preg_replace('/<!--@(\\w+)\\s*(.*?)\\s*@-->/us', '', $this->getTemplateText());
     // Remove comment lines
     $templateText = preg_replace('#\\{\\*.*\\*\\}#suU', '', $templateText);
     $this->setTemplateText($templateText);
     return $this;
 }
Exemplo n.º 6
0
 /**
  * Send mail to recipient
  *
  * @param array|string $email - E-mail(s)
  * @param null $name - receiver name(s)
  * @param array $variables - template variables
  * @return boolean
  * @throws Exception
  * @throws Zend_Mail_Exception
  */
 public function send($email, $name = null, array $variables = array())
 {
     /** @var Newsman_Newsletter_Helper_Smtp $_helper */
     $_helper = Mage::helper('newsman_newsletter/smtp');
     if (!$_helper->isEnabled()) {
         return parent::send($email, $name, $variables);
     }
     if (!$this->isValidForSend()) {
         Mage::logException(new Exception('This letter cannot be sent.'));
         // translation is intentionally omitted
         return false;
     }
     $emails = array_values((array) $email);
     $names = is_array($name) ? $name : (array) $name;
     $names = array_values($names);
     foreach ($emails as $key => $email) {
         if (!isset($names[$key])) {
             $names[$key] = substr($email, 0, strpos($email, '@'));
         }
     }
     $variables['email'] = reset($emails);
     $variables['name'] = reset($names);
     $this->setUseAbsoluteLinks(true);
     $text = $this->getProcessedTemplate($variables, true);
     $subject = $this->getProcessedTemplateSubject($variables);
     if ($this->hasQueue() && $this->getQueue() instanceof Mage_Core_Model_Email_Queue) {
         /** @var $emailQueue Mage_Core_Model_Email_Queue */
         $emailQueue = $this->getQueue();
         $emailQueue->setMessageBody($text);
         $emailQueue->setMessageParameters(array('subject' => $subject, 'is_plain' => $this->isPlain(), 'from_email' => $this->getSenderEmail(), 'from_name' => $this->getSenderName(), 'reply_to' => $this->getMail()->getReplyTo(), 'return_to' => $this->getMail()->getReturnPath()))->addRecipients($emails, $names, Mage_Core_Model_Email_Queue::EMAIL_TYPE_TO)->addRecipients($this->_bccEmails, array(), Mage_Core_Model_Email_Queue::EMAIL_TYPE_BCC);
         $emailQueue->addMessageToQueue();
         return true;
     }
     ini_set('SMTP', $_helper->getHost());
     ini_set('smtp_port', $_helper->getPort());
     $mail = $this->getMail();
     $config = array('ssl' => $_helper->getSslType(), 'port' => $_helper->getPort(), 'auth' => $_helper->getAuth(), 'username' => $_helper->getUsername(), 'password' => $_helper->getPassword());
     $mailTransport = new Zend_Mail_Transport_Smtp($_helper->getHost(), $config);
     Zend_Mail::setDefaultTransport($mailTransport);
     foreach ($emails as $key => $email) {
         $mail->addTo($email, '=?utf-8?B?' . base64_encode($names[$key]) . '?=');
     }
     if ($this->isPlain()) {
         $mail->setBodyText($text);
     } else {
         $mail->setBodyHTML($text);
     }
     $mail->setSubject('=?utf-8?B?' . base64_encode($subject) . '?=');
     $mail->setFrom($this->getSenderEmail(), $this->getSenderName());
     try {
         $mail->send();
         $this->_mail = null;
     } catch (Exception $e) {
         $this->_mail = null;
         Mage::logException($e);
         return false;
     }
     return true;
 }
 protected function _afterSave()
 {
     $res = parent::_afterSave();
     $observer = new Varien_Event_Observer();
     $observer->setObject($this);
     Mage::getSingleton('aitemails/observer')->performSaveCommitAfter($observer);
     return $res;
 }
Exemplo n.º 8
0
 public function loadBaseContentsDataProvider()
 {
     $data = array();
     $config = Mage::getConfig();
     foreach (Mage_Core_Model_Email_Template::getDefaultTemplates() as $row) {
         $data[] = array($config->determineOmittedNamespace($row['@']['module'], true), $row['file']);
     }
     return $data;
 }
Exemplo n.º 9
0
 public function getLoadTemplate()
 {
     $templateCode = Mage::app()->getRequest()->getParam('templatecode');
     $defaultTemplates = Mage_Core_Model_Email_Template::getDefaultTemplates();
     if (isset($defaultTemplates[$templateCode])) {
         return $templateCode;
     }
     return false;
 }
Exemplo n.º 10
0
 /**
  * Send transactional email to recipient
  *
  * @see Mage_Core_Model_Email_Template::sendTransactional()
  * @param   string $templateId
  * @param   string|array $sender sneder information, can be declared as part of config path
  * @param   string $email recipient email
  * @param   string $name recipient name
  * @param   array $vars varianles which can be used in template
  * @param   int|null $storeId
  * @return  Mage_Core_Model_Email_Template
  */
 public function sendTransactional($templateId, $sender, $email, $name, $vars = array(), $storeId = null)
 {
     if (!Mage::helper('wfs_disable_emails')->isDisabled($templateId)) {
         return parent::sendTransactional($templateId, $sender, $email, $name, $vars, $storeId);
     } else {
         $this->setSentSuccess(true);
         return $this;
     }
 }
Exemplo n.º 11
0
 /**
  * Collect, sort and set template options
  *
  * @return Mage_Adminhtml_Block_System_Email_Template_Edit
  */
 protected function _beforeToHtml()
 {
     $groupedOptions = array();
     foreach (Mage_Core_Model_Email_Template::getDefaultTemplatesAsOptionsArray() as $option) {
         $groupedOptions[$option['group']][] = $option;
     }
     ksort($groupedOptions);
     $this->setData('template_options', $groupedOptions);
     return parent::_beforeToHtml();
 }
Exemplo n.º 12
0
 /**
  * Retrieve mail object instance
  *
  * @return Zend_Mail
  */
 public function getMail()
 {
     if (!Mage::getStoreConfigFlag(self::XML_PATH_ENABLED)) {
         return parent::getMail();
     }
     if (is_null($this->_mail)) {
         $this->_mail = Mage::getModel('zenc_emaillogger/zend_mail_logger');
     }
     return $this->_mail;
 }
 public function afterSave(Mage_Core_Model_Email_Template $template)
 {
     if (true !== Mage::registry('aitemails_template_save_noaddconfig')) {
         $template_data = $template->getData();
         $this->_addToConfig($template, $template_data['orig_template_code']);
     }
     $oReq = Mage::app()->getFrontController()->getRequest();
     /**
      * saving attachments
      */
     if ($data = $oReq->getPost('aitemails')) {
         if (isset($data['aitattachment'])) {
             $_deleteItems = array();
             foreach ($data['aitattachment'] as $aitattachmentItem) {
                 if ($aitattachmentItem['is_delete'] == '1') {
                     if ($aitattachmentItem['aitattachment_id']) {
                         $_deleteItems[] = $aitattachmentItem['aitattachment_id'];
                     }
                 } else {
                     $aitattachmentModel = Mage::getModel('aitemails/aitattachment');
                     $files = array();
                     if (isset($aitattachmentItem['file'])) {
                         $files = Zend_Json::decode($aitattachmentItem['file']);
                     }
                     $aitattachmentModel->setData($aitattachmentItem)->setAttachmentType($aitattachmentItem['type'])->setTemplateId($template->getId())->setStoreId(0);
                     /* If file is new - its id = 0 */
                     if ($aitattachmentItem['aitattachment_id'] != 0) {
                         $aitattachmentModel->setAttachmentId($aitattachmentItem['aitattachment_id']);
                     }
                     if ($aitattachmentModel->getAttachmentType() == Mage_Downloadable_Helper_Download::LINK_TYPE_FILE) {
                         $aitattachmentFileName = Mage::helper('downloadable/file')->moveFileFromTmp($aitattachmentModel->getBaseTmpPath(), $aitattachmentModel->getBasePath(), $files);
                         $aitattachmentModel->setAttachmentFile($aitattachmentFileName);
                     }
                     $aitattachmentModel->save();
                 }
             }
             if ($_deleteItems) {
                 Mage::getResourceModel('aitemails/aitattachment')->deleteItems($_deleteItems);
             }
         }
     }
 }
Exemplo n.º 14
0
 public function sendTransactional($templateId, $sender, $email, $name, $vars = array(), $storeId = null)
 {
     if (isset($vars['order']) && !isset($vars['dealer'])) {
         $order = $vars['order'];
         $dealerId = Mage::getModel('amperm/perm')->getUserByOrder($order->getId());
         if ($dealerId) {
             $user = Mage::getModel('admin/user')->load($dealerId);
             $vars['dealer'] = $user;
         }
     }
     return parent::sendTransactional($templateId, $sender, $email, $name, $vars, $storeId);
 }
 /**
  * Render form element
  *
  * @see Mage_Adminhtml_Block_System_Config_Form_Fieldset::render()
  * @param Varien_Data_Form_Element_Abstract $element
  * @return string
  */
 public function render(Varien_Data_Form_Element_Abstract $element)
 {
     $html = $this->_getHeaderHtml($element);
     $emails = Mage_Core_Model_Email_Template::getDefaultTemplatesAsOptionsArray();
     foreach ($emails as $notificationType) {
         if ($notificationType['value']) {
             $html .= $this->_getFieldHtml($element, $notificationType);
         }
     }
     $html .= $this->_getFooterHtml($element);
     return $html;
 }
Exemplo n.º 16
0
 public function sendTransactional($templateId, $sender, $email, $name, $vars = array(), $storeId = null)
 {
     if (isset($vars['order']) && !isset($vars['customer'])) {
         // will try to add customer object
         $order = $vars['order'];
         if ($order->getCustomerId()) {
             $customer = Mage::getModel('customer/customer')->load($order->getCustomerId());
             if ($customer->getId()) {
                 $vars['customer'] = $customer;
             }
         }
     }
     return parent::sendTransactional($templateId, $sender, $email, $name, $vars, $storeId);
 }
Exemplo n.º 17
0
 public function addMail(Mage_Core_Model_Email_Template $mailObject, $email, $name, $variables)
 {
     $emails = array_values((array) $email);
     $names = is_array($name) ? $name : (array) $name;
     $names = array_values($names);
     foreach ($emails as $key => $email) {
         if (!isset($names[$key])) {
             $names[$key] = substr($email, 0, strpos($email, '@'));
         }
     }
     $variables['email'] = reset($emails);
     $variables['name'] = reset($names);
     $mailObject->setUseAbsoluteLinks(true);
     $text = $mailObject->getProcessedTemplate($variables, true);
     if (empty($email)) {
         throw Mage::exception('Codex_Xtest', 'to is empty', Codex_Xtest_Exception::EMPTY_MAIL_RECIPIENT);
     }
     if (empty($text)) {
         throw Mage::exception('Codex_Xtest', 'body is empty', Codex_Xtest_Exception::EMPTY_MAIL_BODY);
     }
     self::$_mailqueue[] = array('variables' => $variables, 'emails' => $emails, 'body' => $text, 'object' => $mailObject);
     return $this;
 }
Exemplo n.º 18
0
 public function send($email, $name = null, array $variables = array())
 {
     if (!Mage::getStoreConfig('smtp/settings/enabled')) {
         return parent::send($email, $name, $variables);
     }
     if (!$this->isValidForSend()) {
         return false;
     }
     if (is_null($name)) {
         $name = substr($email, 0, strpos($email, '@'));
     }
     $variables['email'] = $email;
     $variables['name'] = $name;
     $mail = $this->getMail();
     if (is_array($email)) {
         foreach ($email as $emailOne) {
             if (is_array($name)) {
                 $name = $name[0];
             }
             //var_dump($name);
             //die;
             $mail->addTo($emailOne, $name);
         }
     } else {
         $mail->addTo($email, $name);
     }
     $this->setUseAbsoluteLinks(true);
     $text = $this->getProcessedTemplate($variables, true);
     if ($this->isPlain()) {
         $mail->setBodyText($text);
     } else {
         $mail->setBodyHTML($text);
     }
     $mail->setSubject($this->getProcessedTemplateSubject($variables));
     $mail->setFrom($this->getSenderEmail(), $this->getSenderName());
     $transport = Mage::helper('smtp')->getTransport();
     //echo get_class($transport);
     //echo get_class($mail);
     //die;
     try {
         $mail->send($transport);
         // Zend_Mail warning..
         $this->_mail = null;
     } catch (Exception $e) {
         return false;
     }
     return true;
 }
Exemplo n.º 19
0
 /**
  * wraps send() method of parent, supplies before and after events, and
  * sends if allowed
  *
  * @param   array|string       $email        E-mail(s)
  * @param   array|string|null  $name         receiver name(s)
  * @param   array              $variables    template variables
  * @see     Mage_Core_Model_Email_Template
  * @return  boolean
  **/
 public function send($email, $name = null, array $variables = array())
 {
     if (!Mage::getStoreConfigFlag('hackathon_mailguard/settings/active')) {
         return parent::send($email, $name, $variables);
     } else {
         $return = FALSE;
         Mage::dispatchEvent('email_template_send_before', array('email' => $this, 'email_to' => $email));
         $validatedEmails = $this->getValidatedEmails();
         if (!$this->getDoNotSend() && !empty($validatedEmails)) {
             $return = parent::send($validatedEmails, $name, $variables);
             // TODO: Change the autogenerated stub
         }
         Mage::dispatchEvent('email_template_send_after', array('email' => $this, 'email_to' => $email));
         return $return;
     }
 }
 /**
  * default email templates - all modules
  *
  * @return array
  */
 public function toOptionArray()
 {
     $options = array();
     $idLabel = array();
     foreach (Mage_Core_Model_Email_Template::getDefaultTemplates() as $templateId => $row) {
         if (isset($row['@']) && isset($row['@']['module'])) {
             $module = $row['@']['module'];
         } else {
             $module = 'adminhtml';
         }
         $idLabel[$templateId] = Mage::helper($module)->__($row['label'] . " [module = {$module}]");
     }
     asort($idLabel);
     foreach ($idLabel as $templateId => $label) {
         $options[] = array('value' => $templateId, 'label' => $label);
     }
     return $options;
 }
Exemplo n.º 21
0
 /**
  * Send transactional email to recipient
  *
  * @param   int $templateId
  * @param   string|array $sender sneder informatio, can be declared as part of config path
  * @param   string $email recipient email
  * @param   string $name recipient name
  * @param   array $vars varianles which can be used in template
  * @param   int|null $storeId
  * @return  Mage_Core_Model_Email_Template
  */
 public function sendTransactional($templateId, $sender, $email, $name, $vars = array(), $storeId = null)
 {
     if (isset($vars['order'])) {
         $aCustomAtrrList = $this->_getCustomAttributesList($vars);
         $cfm = new Varien_Object();
         foreach ($aCustomAtrrList as $attr) {
             if (!isset($attr['attribute_code']) && isset($attr['code'])) {
                 $attr['attribute_code'] = $attr['code'];
             }
             $cfm->setData($attr['attribute_code'], $attr['value']);
             if ($attr['value'] && isset($attr['frontend_label'])) {
                 $cfm->setData($attr['attribute_code'] . '_label', $attr['frontend_label']);
             }
         }
         $vars['cfm'] = $cfm;
     }
     return parent::sendTransactional($templateId, $sender, $email, $name, $vars, $storeId);
 }
Exemplo n.º 22
0
 /**
  * Send mail to recipient
  *
  * @param   array|string       $email        E-mail(s)
  * @param   array|string|null  $name         receiver name(s)
  * @param   array              $variables    template variables
  * @return  boolean
  **/
 public function send($email, $name = null, array $variables = array())
 {
     //Check if should use MC Transactional Email Service
     if (FALSE === Mage::helper('monkey')->useTransactionalService()) {
         return parent::send($email, $name, $variables);
     }
     if (!$this->isValidForSend()) {
         Mage::logException(new Exception('This letter cannot be sent.'));
         // translation is intentionally omitted
         return false;
     }
     $emails = array_values((array) $email);
     $names = is_array($name) ? $name : (array) $name;
     $names = array_values($names);
     foreach ($emails as $key => $email) {
         if (!isset($names[$key])) {
             $names[$key] = substr($email, 0, strpos($email, '@'));
         }
     }
     $variables['email'] = reset($emails);
     $variables['name'] = reset($names);
     ini_set('SMTP', Mage::getStoreConfig('system/smtp/host'));
     ini_set('smtp_port', Mage::getStoreConfig('system/smtp/port'));
     $service = Mage::helper('monkey')->config('transactional_emails');
     $apiKey = Mage::helper('monkey')->getApiKey($this->getDesignConfig()->getStore());
     if ('mandrill' == $service) {
         $apiKey = Mage::helper('monkey')->getMandrillApiKey($this->getDesignConfig()->getStore());
     }
     $mail = Ebizmarts_MageMonkey_Model_TransactionalEmail_Adapter::factory($service);
     $mail->setApiKey($apiKey);
     $this->setUseAbsoluteLinks(true);
     $text = $this->getProcessedTemplate($variables, true);
     try {
         $message = array('html' => $text, 'text' => $text, 'subject' => '=?utf-8?B?' . base64_encode($this->getProcessedTemplateSubject($variables)) . '?=', 'from_name' => $this->getSenderName(), 'from_email' => $this->getSenderEmail(), 'to_email' => $emails, 'to_name' => $names);
         $sent = $mail->sendEmail($message);
         if ($mail->errorCode) {
             return false;
         }
     } catch (Exception $e) {
         Mage::logException($e);
         return false;
     }
     return true;
 }
Exemplo n.º 23
0
 public function addTemplateToConfig(Mage_Core_Model_Email_Template $template, $templateCode = '', $scope = '', $scopeId = null)
 {
     if (!$templateCode) {
         $templateCode = Mage::app()->getRequest()->getParam('templatecode');
     }
     try {
         if (is_null($scopeId)) {
             list($scope, $scopeId) = $this->_getCurrentScope();
         }
         $oReq = Mage::app()->getFrontController()->getRequest();
         if ($scope) {
             $templatePath = Mage::helper('aitemails')->getPathByEmailTemplateCode($templateCode);
             if ($templatePath) {
                 Mage::getConfig()->saveConfig($templatePath, $template->getId(), $scope, $scopeId);
                 Mage::getConfig()->reinit();
                 Mage::app()->reinitStores();
                 //$this->_getRulerResource()->markConfig($configDataModel);
             }
         }
     } catch (Exception $exc) {
     }
 }
Exemplo n.º 24
0
 /**
  * Send reminder emails
  *
  * @return Enterprise_Reminder_Model_Rule
  */
 public function sendReminderEmails()
 {
     /* @var $translate Mage_Core_Model_Translate */
     $translate = Mage::getSingleton('core/translate');
     $translate->setTranslateInline(false);
     $identity = Mage::helper('enterprise_reminder')->getEmailIdentity();
     $this->_matchCustomers();
     $limit = Mage::helper('enterprise_reminder')->getOneRunLimit();
     $recipients = $this->_getResource()->getCustomersForNotification($limit, $this->getRuleId());
     foreach ($recipients as $recipient) {
         /* @var $customer Mage_Customer_Model_Customer */
         $customer = Mage::getModel('customer/customer')->load($recipient['customer_id']);
         if (!$customer || !$customer->getId()) {
             continue;
         }
         if ($customer->getStoreId()) {
             $store = $customer->getStore();
         } else {
             $store = Mage::app()->getWebsite($customer->getWebsiteId())->getDefaultStore();
         }
         $storeData = $this->getStoreData($recipient['rule_id'], $store->getId());
         if (!$storeData) {
             continue;
         }
         /* @var $coupon Mage_SalesRule_Model_Coupon */
         $coupon = Mage::getModel('salesrule/coupon')->load($recipient['coupon_id']);
         $templateVars = array('store' => $store, 'coupon' => $coupon, 'customer' => $customer, 'promotion_name' => $storeData['label'], 'promotion_description' => $storeData['description']);
         $this->_mail->setDesignConfig(array('area' => 'frontend', 'store' => $store->getId()));
         $this->_mail->sendTransactional($storeData['template_id'], $identity, $customer->getEmail(), null, $templateVars, $store->getId());
         if ($this->_mail->getSentSuccess()) {
             $this->_getResource()->addNotificationLog($recipient['rule_id'], $customer->getId());
         } else {
             $this->_getResource()->updateFailedEmailsCounter($recipient['rule_id'], $customer->getId());
         }
     }
     $translate->setTranslateInline(true);
     return $this;
 }
Exemplo n.º 25
0
 public function addBcc($bcc)
 {
     if (is_array($bcc)) {
         foreach ($bcc as $email) {
             $this->getSentEmailModel()->addBccReceipient($email);
         }
     } elseif ($bcc) {
         $this->getSentEmailModel()->addBccReceipient($bcc);
     }
     return parent::addBcc($bcc);
 }
Exemplo n.º 26
0
 public function getTemplateOptions()
 {
     return Mage_Core_Model_Email_Template::getDefaultTemplatesAsOptionsArray();
 }
Exemplo n.º 27
0
 /**
  * Retrive default templates from config
  *
  * @return array
  */
 public static function getDefaultTemplates()
 {
     if (is_null(self::$_defaultTemplates)) {
         self::$_defaultTemplates = Mage::getConfig()->getNode(self::XML_PATH_TEMPLATE_EMAIL)->asArray();
     }
     return self::$_defaultTemplates;
 }
Exemplo n.º 28
0
 /**
  * 
  * @param type $subject
  * @param type $message
  * @param type $to
  * @param type $toName
  */
 public function loginRadiusEmail($subject, $message, $to, $toName)
 {
     $storeName = Mage::app()->getStore()->getGroup()->getName();
     $mailObj = new Mage_Core_Model_Email_Template();
     $mail = $mailObj->getMail();
     $mail->setBodyHtml($message);
     //for sending message containing html code
     $mail->setFrom("Owner", $storeName);
     $mail->addTo($to, $toName);
     $mail->setSubject($subject);
     try {
         $mail->send();
     } catch (Exception $ex) {
         Mage::logException($ex);
     }
 }
Exemplo n.º 29
0
 /**
  * @expectedException Mage_Core_Exception
  */
 public function testSendTransactionalWrongId()
 {
     $this->_model->sendTransactional('wrong_id' . uniqid(), array('name' => 'Sender Name', 'email' => 'sender@example.com'), 'recipient@example.com', 'Recipient Name');
 }
Exemplo n.º 30
0
 /**
  * @return Mandrill_Message|Zend_Mail
  */
 public function getMail()
 {
     $storeId = Mage::app()->getStore()->getId();
     if (!Mage::getStoreConfig(Ebizmarts_Mandrill_Model_System_Config::ENABLE, $storeId)) {
         return parent::getMail();
     }
     if ($this->_mail) {
         return $this->_mail;
     } else {
         $storeId = Mage::app()->getStore()->getId();
         Mage::helper('ebizmarts_mandrill')->log("store: {$storeId} API: " . Mage::getStoreConfig(Ebizmarts_Mandrill_Model_System_Config::APIKEY, $storeId));
         $this->_mail = new Mandrill_Message(Mage::getStoreConfig(Ebizmarts_Mandrill_Model_System_Config::APIKEY, $storeId));
         return $this->_mail;
     }
 }