class SendGrid extends Mailer (View source)

Mailer to be used with SendGrid Web API

Properties

protected HttpClient $httpClient from Mailer
protected string $serverToken from Mailer

Methods

__construct(HttpClient $httpClient, string $serverToken)

No description

from Mailer
setHttpClient(HttpClient $httpClient)

No description

from Mailer
setMessageFactory(MessageFactory $messageFactory)

No description

from Mailer
setServerToken($serverToken)

No description

string
getServerToken()

No description

from Mailer
Boolean
send(MessageInterface $message)

No description

from Mailer
array
getHeaders()

Return a key -> value array of headers

from Mailer
string[]
getFiles(MessageInterface $message)

Return an key -> value array of files

string
getEndpoint()

No description

string
format(MessageInterface $message)

Return a a string formatted for the correct Mailer endpoint.

handle(ResponseInterface $response)

If a Response is not successful it will be passed to this method each Mailer should then throw an HttpException with an optional ApiException to help identify the problem.

normalizeIdentity(IdentityInterface|string $identity)

No description

from Mailer
normalizeIdentities(IdentityInterface[]|string $identities)

No description

from Mailer
string
buildIdentityString(IdentityInterface[]|IdentityInterface|string $identities)

No description

from Mailer
array
processAttachments(array $attachments)

No description

Details

__construct(HttpClient $httpClient, string $serverToken)

Parameters

HttpClient $httpClient
string $serverToken

setHttpClient(HttpClient $httpClient)

Parameters

HttpClient $httpClient

Mailer setMessageFactory(MessageFactory $messageFactory)

Parameters

MessageFactory $messageFactory

Return Value

Mailer

setServerToken($serverToken)

Parameters

$serverToken

string getServerToken()

Return Value

string

Boolean send(MessageInterface $message)

Parameters

MessageInterface $message

Return Value

Boolean

protected array getHeaders()

Return a key -> value array of headers

example: array('X-Header-Name' => 'value')

Return Value

array

protected string[] getFiles(MessageInterface $message)

Return an key -> value array of files

example: array('attachmentname.jpg' => '/path/to/file.jpg')

Parameters

MessageInterface $message

Return Value

string[]

protected string getEndpoint()

Return Value

string

protected string format(MessageInterface $message)

Return a a string formatted for the correct Mailer endpoint.

Postmark this is Json, SendGrid it is a urlencoded parameter list

Parameters

MessageInterface $message

Return Value

string

protected handle(ResponseInterface $response)

If a Response is not successful it will be passed to this method each Mailer should then throw an HttpException with an optional ApiException to help identify the problem.

Parameters

ResponseInterface $response

Exceptions

ApiException
HttpException

protected IdentityInterface normalizeIdentity(IdentityInterface|string $identity)

Parameters

IdentityInterface|string $identity

Return Value

IdentityInterface

protected IdentityInterface[] normalizeIdentities(IdentityInterface[]|string $identities)

Parameters

IdentityInterface[]|string $identities

Return Value

IdentityInterface[]

protected string buildIdentityString(IdentityInterface[]|IdentityInterface|string $identities)

Parameters

IdentityInterface[]|IdentityInterface|string $identities

Return Value

string

protected array processAttachments(array $attachments)

Parameters

array $attachments

Return Value

array First element: All attachments – array(name => path). Second element: Inline attachments – array(id => name)