Example #1
0
 /**
  * Forgot password
  *
  * @return void
  */
 public function forgotpasswordAction()
 {
     $this->view->title = __('forgot password page title');
     $authVars = Garp_Auth::getInstance()->getConfigValues('forgotpassword');
     $this->view->successMessage = intval($this->getRequest()->getParam('success')) === 1 ? __($authVars['success_message']) : null;
     if (!$this->getRequest()->isPost()) {
         return;
     }
     if ($this->getRequest()->getPost(self::HONEYPOT_COLUMN)) {
         throw new Garp_Auth_Exception(__('honeypot error'));
     }
     $this->view->email = $email = $this->getRequest()->getPost('email');
     $userModel = new Model_User();
     if (!($user = $userModel->fetchByEmail($email))) {
         $this->view->formError = __('email addr not found');
         return;
     }
     $activationToken = uniqid();
     $activationCode = Garp_Auth::getInstance()->generateActivationCodeForUser($activationToken, $email, $user->id);
     $activationCodeExpiry = Garp_Auth::getInstance()->generateActivationCodeExpiry();
     $userModel->updateUserWithActivationCode($user->id, $activationToken, $activationCodeExpiry);
     // @todo Use named route for this
     $activationUrl = '/g/auth/resetpassword/c/' . $activationCode . '/e/' . md5($email) . '/';
     $messageFormat = Garp_Auth::getInstance()->getForgotPasswordMessageFormat();
     $message = Garp_Auth::getInstance()->getForgotPasswordEmailMessage($user, $activationUrl);
     $messageParam = $messageFormat === 'html' ? 'htmlMessage' : 'message';
     $mailer = new Garp_Mailer();
     $mailer->send(array('to' => $email, $messageParam => $message, 'subject' => __($authVars['email_subject'])));
     if (isset($authVars['route'])) {
         $this->_helper->redirector->gotoRoute(array('success' => 1), $authVars['route']);
     } elseif (isset($authVars['url'])) {
         $targetUrl = $authVars['url'];
         $this->_helper->redirector->gotoUrl($targetUrl . '?success=1');
     }
 }
Example #2
0
 /**
  * Mail an error to an admin
  *
  * @param ArrayObject $errors
  * @return void
  */
 public static function mailErrorToAdmin(ArrayObject $errors)
 {
     $errorMessage = self::_composeFullErrorMessage($errors);
     $subjectPrefix = '';
     if (isset($_SERVER) && !empty($_SERVER['HTTP_HOST'])) {
         $subjectPrefix = '[' . $_SERVER['HTTP_HOST'] . '] ';
     }
     $ini = Zend_Registry::get('config');
     $to = isset($ini->app) && isset($ini->app->errorReportEmailAddress) && $ini->app->errorReportEmailAddress ? $ini->app->errorReportEmailAddress : self::ERROR_REPORT_MAIL_ADDRESS_FALLBACK;
     $mailer = new Garp_Mailer();
     return $mailer->send(array('to' => $to, 'subject' => $subjectPrefix . 'An application error occurred', 'message' => $errorMessage));
 }
Example #3
0
 protected function _sendTokenEmail($email, $userId, $token)
 {
     $mailer = new Garp_Mailer();
     return $mailer->send(array('to' => $email, 'subject' => $this->_getEmailSubject(), 'message' => $this->_getEmailBody($userId, $token)));
 }
Example #4
0
 public function test_mailer_should_mail()
 {
     $this->_helper->injectConfigValues(array('mailer' => array('template' => null, 'attachments' => null)));
     $targetPath = GARP_APPLICATION_PATH . '/../tests/tmp';
     $mailer = new Garp_Mailer();
     $mailer->setTransport(new Zend_Mail_Transport_File(array('path' => $targetPath, 'callback' => function () {
         return 'mail.txt';
     })));
     $mailer->send($this->_getParams());
     $this->assertTrue(file_exists($targetPath . '/mail.txt'));
     /**
      * Note: verifying the contents of the file would be testing Zend_Mail_Transport_File.
      * Let's for now assume if the file is there, the content is correct.
      */
     unlink($targetPath . '/mail.txt');
 }
Example #5
0
 /**
  * Send validation email to the user
  * @param Garp_Db_Table_Row $user The user
  * @param String $code The validation code
  * @param String $updateOrInsert Wether this was caused by an insert or an update
  * @return Boolean
  */
 public function sendEmailValidationEmail(Garp_Db_Table_Row $user, $code, $updateOrInsert = 'insert')
 {
     $authVars = Garp_Auth::getInstance()->getConfigValues('validateemail');
     // Render the email message
     $activationUrl = '/g/auth/validateemail/c/' . $code . '/e/' . md5($user->email) . '/';
     if (!empty($authVars['email_partial'])) {
         $bootstrap = Zend_Controller_Front::getInstance()->getParam('bootstrap');
         $view = $bootstrap->getResource('View');
         $emailMessage = $view->partial($authVars['email_partial'], 'default', array('user' => $user, 'activationUrl' => $activationUrl, 'updateOrInsert' => $updateOrInsert));
         $messageParam = 'htmlMessage';
     } else {
         $snippetId = 'validate email ';
         $snippetId .= $updateOrInsert == 'insert' ? 'new user' : 'existing user';
         $snippetId .= ' email';
         $emailMessage = __($snippetId);
         $emailMessage = Garp_Util_String::interpolate($emailMessage, array('USERNAME' => (string) new Garp_Util_FullName($user), 'ACTIVATION_URL' => (string) new Garp_Util_FullUrl($activationUrl)));
         $messageParam = 'message';
     }
     $mailer = new Garp_Mailer();
     return $mailer->send(array('to' => $user->email, 'subject' => __($authVars['email_subject']), $messageParam => $emailMessage));
 }
Example #6
0
 /**
  * Throw exception and do some logging.
  * @param Exception $e
  * @param String $method
  * @param Array $args
  * @return Void
  */
 protected function _throwException(Exception $e, $method, $args = array())
 {
     $this->_logTraffic();
     // Mail Amstelfilm about this error
     $ini = Zend_Registry::get('config');
     if (!empty($ini->gofilex->errorReportEmailAddress)) {
         $to = $ini->gofilex->errorReportEmailAddress;
         $subject = 'Gofilex error report';
         $message = "Hallo,\n\r\n\r" . "Er is een Gofilex fout opgetreden. Hier vindt u de details:\n\r\n\r" . "Fout: " . $e->getMessage() . "\n\r" . "Gofilex API functie: {$method}\n\r" . "Parameters:\n";
         foreach ($args as $key => $value) {
             $message .= "{$key}: {$value}\n\r";
         }
         // Especially interesting is the submitted POST data, since here
         // user-submitted movie data will reside
         $message .= "\n\rPOST data (ingevuld in het formulier):\n\r";
         if (empty($_POST)) {
             $message .= "-\n\r";
         } else {
             foreach ($_POST as $key => $value) {
                 $message .= "{$key}: {$value}\n\r";
             }
         }
         $mailer = new Garp_Mailer();
         $mailer->send(array('to' => $to, 'subject' => $subject, 'message' => $message));
     }
     throw $e;
 }
Example #7
0
 protected function _broadcastByMail($version)
 {
     $config = Zend_Registry::get('config');
     if (!isset($config->gumball->notificationEmail) || !$config->gumball->notificationEmail) {
         return;
     }
     $mailer = new Garp_Mailer();
     $mailer->send(array('to' => $config->gumball->notificationEmail, 'subject' => sprintf($this->_getRestoreEmailSubject(), $config->app->name), 'message' => sprintf($this->_getRestoreEmailMessage(), $config->app->name, APPLICATION_ENV, $version, $config->app->domain)));
 }