Beispiel #1
0
 public function testGetLabel_typeNotConfigured()
 {
     $actor = CMTest_TH::createUser();
     $typeEmail = mt_rand();
     $action = new CM_Action_Email(CM_Action_Abstract::VIEW, $actor, $typeEmail);
     $this->assertSame('Email View ' . $typeEmail, $action->getLabel());
 }
Beispiel #2
0
 protected function _execute(CM_Params $params)
 {
     CM_Service_Manager::getInstance()->getMailer()->send($params->getMailMessage('message'));
     if ($params->has('recipient') && $params->has('mailType')) {
         $recipient = $params->getUser('recipient');
         $mailType = $params->getInt('mailType');
         $action = new CM_Action_Email(CM_Action_Abstract::SEND, $recipient, $mailType);
         $action->prepare($recipient);
         $action->notify($recipient);
     }
 }
Beispiel #3
0
 protected function _process()
 {
     $params = CM_Params::factory($this->_request->getQuery(), true);
     try {
         $user = $params->getUser('user');
         $mailType = $params->getInt('mailType');
         $action = new CM_Action_Email(CM_Action_Abstract::VIEW, $user, $mailType);
         $action->prepare();
         $action->notify($user, $mailType);
     } catch (CM_Exception $e) {
         if (in_array(get_class($e), ['CM_Exception_Nonexistent', 'CM_Exception_InvalidParam'])) {
             $e->setSeverity(CM_Exception::WARN);
         }
         throw $e;
     }
     $this->setHeader('Content-Type', 'image/gif');
     $this->_setContent(base64_decode('R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=='));
 }
Beispiel #4
0
 public function testProcess()
 {
     $user = $this->getMockUser();
     $mail = new CM_Mail_ExampleMailable($user);
     $site = CM_Site_Abstract::factory();
     $render = new CM_Frontend_Render(new CM_Frontend_Environment($site));
     $request = new CM_Http_Request_Get($render->getUrlEmailTracking($mail), ['host' => $site->getHost()]);
     $response = CM_Http_Response_EmailTracking::createFromRequest($request, $site, $this->getServiceManager());
     $response->process();
     $actionList = new CM_Paging_Action_User($user, CM_Action_Email::getTypeStatic(), CM_Action_Abstract::getVerbByVerbName(CM_Action_Abstract::VIEW));
     $this->assertSame(1, $actionList->getCount());
 }
Beispiel #5
0
 /**
  * @throws CM_Exception_Invalid
  */
 protected function _send($subject, $text, $html = null)
 {
     if (!self::_getConfig()->send) {
         $this->_log($subject, $text);
     } else {
         $phpMailer = $this->_getPHPMailer();
         foreach ($this->_replyTo as $replyTo) {
             $phpMailer->AddReplyTo($replyTo['address'], $replyTo['name']);
         }
         foreach ($this->_to as $to) {
             $phpMailer->AddAddress($to['address'], $to['name']);
         }
         foreach ($this->_cc as $cc) {
             $phpMailer->AddCC($cc['address'], $cc['name']);
         }
         foreach ($this->_bcc as $bcc) {
             $phpMailer->AddBCC($bcc['address'], $bcc['name']);
         }
         if ($mailDeliveryAgent = $this->_getMailDeliveryAgent()) {
             $this->addCustomHeader('X-MDA', $mailDeliveryAgent);
         }
         if ($headerList = $this->_getCustomHeaders()) {
             foreach ($headerList as $label => $value) {
                 $phpMailer->AddCustomHeader($label, implode(',', $value));
             }
         }
         $phpMailer->SetFrom($this->_sender['address'], $this->_sender['name']);
         $phpMailer->Subject = $subject;
         $phpMailer->IsHTML($html);
         $phpMailer->Body = $html ? $html : $text;
         $phpMailer->AltBody = $html ? $text : '';
         try {
             $phpMailer->Send();
         } catch (phpmailerException $e) {
             throw new CM_Exception_Invalid('Cannot send email, phpmailer reports: ' . $e->getMessage());
         }
         if ($recipient = $this->getRecipient()) {
             $action = new CM_Action_Email(CM_Action_Abstract::SEND, $recipient, $this->getType());
             $action->prepare($recipient);
             $action->notify($recipient);
         }
     }
 }