Beispiel #1
0
 /**
  * Clean up after sending the mail
  *
  * @param PostmanZendMailEngine $engine        	
  * @param unknown $startTime        	
  */
 private function postSend(PostmanMailEngine $engine, $startTime, PostmanOptions $options, PostmanModuleTransport $transport)
 {
     // save the transcript
     $this->transcript = $engine->getTranscript();
     // log the transcript
     if ($this->logger->isTrace()) {
         $this->logger->trace('Transcript:');
         $this->logger->trace($this->transcript);
     }
     // delete the semaphore
     if ($transport->isLockingRequired()) {
         PostmanUtils::unlock();
     }
     // stop the clock
     $endTime = microtime(true) * 1000;
     $this->totalTime = $endTime - $startTime;
 }
 /**
  * Handles the authorization grant
  */
 function handleAuthorizationGrant()
 {
     $logger = $this->logger;
     $options = $this->options;
     $authorizationToken = $this->authorizationToken;
     $logger->debug('Authorization in progress');
     $transactionId = PostmanSession::getInstance()->getOauthInProgress();
     // begin transaction
     PostmanUtils::lock();
     $authenticationManager = PostmanAuthenticationManagerFactory::getInstance()->createAuthenticationManager(PostmanTransportRegistry::getInstance()->getCurrentTransport(), $options, $authorizationToken);
     try {
         if ($authenticationManager->processAuthorizationGrantCode($transactionId)) {
             $logger->debug('Authorization successful');
             // save to database
             $authorizationToken->save();
             $this->messageHandler->addMessage(__('The OAuth 2.0 authorization was successful. Ready to send e-mail.', 'postman-smtp'));
         } else {
             $this->messageHandler->addError(__('Your email provider did not grant Postman permission. Try again.', 'postman-smtp'));
         }
     } catch (PostmanStateIdMissingException $e) {
         $this->messageHandler->addError(__('The grant code from Google had no accompanying state and may be a forgery', 'postman-smtp'));
     } catch (Exception $e) {
         $logger->error('Error: ' . get_class($e) . ' code=' . $e->getCode() . ' message=' . $e->getMessage());
         /* translators: %s is the error message */
         $this->messageHandler->addError(sprintf(__('Error authenticating with this Client ID. [%s]', 'postman-smtp'), '<em>' . $e->getMessage() . '</em>'));
     }
     // clean-up
     PostmanUtils::unlock();
     PostmanSession::getInstance()->unsetOauthInProgress();
     // redirect home
     PostmanUtils::redirect(PostmanUtils::POSTMAN_HOME_PAGE_RELATIVE_URL);
 }
Beispiel #3
0
 /**
  * Clean up after sending the mail
  *
  * @param PostmanMailEngine $engine        	
  * @param unknown $startTime        	
  */
 private function postSend(PostmanMailEngine $engine, $startTime, PostmanOptions $options)
 {
     // save the transcript
     $this->transcript = $engine->getTranscript();
     // delete the semaphore
     if ($options->isAuthTypeOAuth2()) {
         PostmanUtils::unlock();
     }
     // stop the clock
     $endTime = microtime(true) * 1000;
     $this->totalTime = $endTime - $startTime;
 }