Blesta Source Documentation

Oauth2Transport extends EsmtpTransport

Sends Emails over SMTP with ESMTP support using OAuth2 authentication.

Table of Contents

Properties

$auth_code
$authenticators
$client_id
$client_secret
$provider
$providers
$redirect_uri
$refresh_token

Methods

__construct() Initializes OAuth2 transport
getAccessToken() Returns the OAuth2 Access Token
getAuthorizationCode() Returns the OAuth2 Authorization Code
getAuthorizationUrl() Returns the authorization URL for the current provider
getClientId() Returns the OAuth2 Client ID
getClientSecret() Returns the OAuth2 Client Secret
getProvider() Returns the current OAuth2.0 provider
getRedirectUri() Returns the OAuth2 Redirect URI
getRefreshToken() Returns the OAuth2 Refresh Token
getScope() Returns the authorization scope for the current provider
refreshAccessToken() Updates the OAuth 2.0 tokens
setAccessToken() Set the OAuth2 Access Token
setAuthorizationCode() Set the OAuth2 Authorization Code
setClientId() Set the OAuth2 Client ID
setClientSecret() Set the OAuth2 Client Secret
setProvider() Sets the OAuth2.0 provider to use
setRedirectUri() Set the OAuth2 Redirect URI
setRefreshToken() Set the OAuth2 Refresh Token
Properties

$providers

private mixed $providers = ['google' => ['smtp' => 'smtp.gmail.com', 'authorization_endpoint' => 'https://accounts.google.com/o/oauth2/v2/auth', 'token_endpoint' => 'https://oauth2.googleapis.com/token', 'scope' => ['https://mail.google.com/']], 'microsoft' => ['smtp' => 'smtp-mail.outlook.com', 'authorization_endpoint' => 'https://login.microsoftonline.com/common/oauth2/v2.0/authorize', 'token_endpoint' => 'https://login.microsoftonline.com/common/oauth2/v2.0/token', 'scope' => ['offline_access', 'https://outlook.office.com/IMAP.AccessAsUser.All', 'https://outlook.office.com/POP.AccessAsUser.All', 'https://outlook.office.com/SMTP.Send']]]
Methods

__construct()

Initializes OAuth2 transport

public __construct([string $host = 'localhost' ][, int $port = 0 ][, bool|null $tls = null ][, EventDispatcherInterface|null $dispatcher = null ][, LoggerInterface|null $logger = null ]) : mixed
Parameters
$host : string = 'localhost'
$port : int = 0
$tls : bool|null = null
$dispatcher : EventDispatcherInterface|null = null
$logger : LoggerInterface|null = null

getAccessToken()

Returns the OAuth2 Access Token

public getAccessToken() : $this
Return values
$this

An instance of this object

getAuthorizationCode()

Returns the OAuth2 Authorization Code

public getAuthorizationCode() : $this
Return values
$this

An instance of this object

getAuthorizationUrl()

Returns the authorization URL for the current provider

public getAuthorizationUrl([array<string|int, mixed> $params = [] ]) : string
Parameters
$params : array<string|int, mixed> = []

An array of URI parameters to pass to authorization endpoint (optional)

Return values
string

The authorization URL of the provider

getClientId()

Returns the OAuth2 Client ID

public getClientId() : $this
Return values
$this

An instance of this object

getClientSecret()

Returns the OAuth2 Client Secret

public getClientSecret() : $this
Return values
$this

An instance of this object

getProvider()

Returns the current OAuth2.0 provider

public getProvider() : array<string|int, mixed>
Return values
array<string|int, mixed>

An array representing the current provider, null if provider doesn't exist or hasn't been defined

getRedirectUri()

Returns the OAuth2 Redirect URI

public getRedirectUri() : $this
Return values
$this

An instance of this object

getRefreshToken()

Returns the OAuth2 Refresh Token

public getRefreshToken() : $this
Return values
$this

An instance of this object

getScope()

Returns the authorization scope for the current provider

public getScope() : string
Return values
string

The authorization scope of the provider

refreshAccessToken()

Updates the OAuth 2.0 tokens

public refreshAccessToken([bool $initial = false ][, bool $save = true ]) : object
Parameters
$initial : bool = false
$save : bool = true
Return values
object

An object containing the new access and refresh token

setAccessToken()

Set the OAuth2 Access Token

public setAccessToken(string $password) : $this
Parameters
$password : string
Return values
$this

An instance of this object

setAuthorizationCode()

Set the OAuth2 Authorization Code

public setAuthorizationCode(string $code) : $this
Parameters
$code : string
Return values
$this

An instance of this object

setClientId()

Set the OAuth2 Client ID

public setClientId(string $client_id) : $this
Parameters
$client_id : string
Return values
$this

An instance of this object

setClientSecret()

Set the OAuth2 Client Secret

public setClientSecret(string $client_secret) : $this
Parameters
$client_secret : string
Return values
$this

An instance of this object

setProvider()

Sets the OAuth2.0 provider to use

public setProvider(string $provider) : mixed
Parameters
$provider : string

The provider to use for authentication, it could be 'google' or 'microsoft'

setRedirectUri()

Set the OAuth2 Redirect URI

public setRedirectUri(string $redirect_uri) : $this
Parameters
$redirect_uri : string
Return values
$this

An instance of this object

setRefreshToken()

Set the OAuth2 Refresh Token

public setRefreshToken(string $token) : $this
Parameters
$token : string
Return values
$this

An instance of this object

Tags
subpackage

core.Util.Transport

copyright

Copyright (c) 2025, Phillips Data, Inc.

license

http://www.blesta.com/license/ The Blesta License Agreement

link

Blesta


        
On this page

Search results