/** * (non-PHPdoc) * * @see PostmanZendModuleTransport::createZendMailTransport() */ public function createZendMailTransport($fakeHostname, $fakeConfig) { if (PostmanOptions::AUTHENTICATION_TYPE_OAUTH2 == $this->getAuthenticationType()) { $config = PostmanOAuth2ConfigurationFactory::createConfig($this); } else { $config = PostmanBasicAuthConfigurationFactory::createConfig($this); } // Google's autoloader will try and load this so we list it first require_once 'PostmanGmailApiModuleZendMailTransport.php'; // Gmail Client includes require_once 'google-api-php-client-1.1.2/src/Google/Client.php'; require_once 'google-api-php-client-1.1.2/src/Google/Service/Gmail.php'; // build the Gmail Client $authToken = PostmanOAuthToken::getInstance(); $client = new Postman_Google_Client(); $client->setClientId($this->options->getClientId()); $client->setClientSecret($this->options->getClientSecret()); $client->setRedirectUri(''); // rebuild the google access token $token = new stdClass(); $token->access_token = $authToken->getAccessToken(); $token->refresh_token = $authToken->getRefreshToken(); $token->token_type = 'Bearer'; $token->expires_in = 3600; $token->id_token = null; $token->created = 0; $client->setAccessToken(json_encode($token)); // We only need permissions to compose and send emails $client->addScope("https://www.googleapis.com/auth/gmail.compose"); $service = new Postman_Google_Service_Gmail($client); $config[PostmanGmailApiModuleZendMailTransport::SERVICE_OPTION] = $service; return new PostmanGmailApiModuleZendMailTransport(self::HOST, $config); }
/** * (non-PHPdoc) * * @see PostmanZendModuleTransport::createZendMailTransport() */ public function createZendMailTransport($fakeHostname, $fakeConfig) { if (PostmanOptions::AUTHENTICATION_TYPE_OAUTH2 == $this->getAuthenticationType()) { $config = PostmanOAuth2ConfigurationFactory::createConfig($this); } else { $config = PostmanBasicAuthConfigurationFactory::createConfig($this); } return new Postman_Zend_Mail_Transport_Smtp($this->getHostname(), $config); }