示例#1
0
 protected function _prepareCollection()
 {
     $apiKey = Mage::helper('monkey')->getApiKey(0);
     $mail = Ebizmarts_MageMonkey_Model_TransactionalEmail_Adapter::factory('sts')->setApiKey($apiKey);
     $emails = $mail->listVerifiedEmailAddresses();
     if ($emails !== FALSE) {
         $_emails = array();
         foreach ($emails->email_addresses as $email) {
             $_emails[] = array('email' => $email);
         }
         $collection = Mage::getModel('monkey/custom_collection', array($_emails));
     } else {
         $collection = Mage::getModel('monkey/custom_collection', array(array()));
     }
     $this->setCollection($collection);
     return parent::_prepareCollection();
 }
示例#2
0
 protected function _prepareCollection()
 {
     $apiKey = Mage::helper('monkey')->getMandrillApiKey(0);
     $mail = Ebizmarts_MageMonkey_Model_TransactionalEmail_Adapter::factory('mandrill')->setApiKey($apiKey);
     $emails = $mail->usersSenders();
     if ($emails !== FALSE) {
         $_emails = array();
         foreach ($emails as $email) {
             $_emails[] = array('email' => $email->address, 'created_at' => $email->created_at, 'enabled' => $email->is_enabled === TRUE ? Mage::helper('monkey')->__('Yes') : Mage::helper('monkey')->__('No'));
         }
         $collection = Mage::getModel('monkey/custom_collection', array($_emails));
     } else {
         $collection = Mage::getModel('monkey/custom_collection', array(array()));
     }
     $this->setCollection($collection);
     return parent::_prepareCollection();
 }
 /**
  * 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;
 }
 /**
  * Delete valid email address from Amazon SES
  */
 public function stsDeleteAction()
 {
     $email = $this->getRequest()->getParam('email');
     $store = $this->getRequest()->getParam('store', 0);
     if ($email) {
         $apiKey = Mage::helper('monkey')->getApiKey($store);
         $mail = Ebizmarts_MageMonkey_Model_TransactionalEmail_Adapter::factory('sts')->setApiKey($apiKey);
         $mail->deleteVerifiedEmailAddress($email);
         if ($mail->errorCode) {
             $this->_getSession()->addError($this->__($mail->errorMessage));
         } else {
             $this->_getSession()->addSuccess($this->__('Email address deleted.'));
         }
     }
     $this->_redirect('monkey/adminhtml_transactionalemail/sts');
 }