class Mailer implements Mailer, MailQueue (View source)

Properties

protected Factory $views The view factory instance.
protected Swift_Mailer $swift The Swift Mailer instance.
protected Dispatcher|null $events The event dispatcher instance.
protected array $from The global from address and name.
protected array $to The global to address and name.
protected Container $container The IoC container instance.
protected Queue $queue The queue implementation.
protected array $failedRecipients Array of failed recipients.

Methods

void
__construct(Factory $views, Swift_Mailer $swift, Dispatcher $events = null)

Create a new Mailer instance.

void
alwaysFrom(string $address, string|null $name = null)

Set the global from address and name.

void
alwaysTo(string $address, string|null $name = null)

Set the global to address and name.

to(mixed $users)

Begin the process of mailing a mailable class instance.

bcc(mixed $users)

Begin the process of mailing a mailable class instance.

int
raw(string $text, Closure|string $callback)

Send a new message when only a raw text part.

void
plain(string $view, array $data, mixed $callback)

Send a new message when only a plain part.

void
send(string|array $view, array $data = [], Closure|string $callback = null)

Send a new message using a view.

mixed
queue(string|array $view, array $data = [], Closure|string $callback = null, string $queue = null)

Queue a new e-mail message for sending.

mixed
onQueue(string $queue, string|array $view, array $data, Closure|string $callback)

Queue a new e-mail message for sending on the given queue.

mixed
queueOn(string $queue, string|array $view, array $data, Closure|string $callback)

Queue a new e-mail message for sending on the given queue.

mixed
later(int $delay, string|array $view, array $data = [], Closure|string $callback = null, string $queue = null)

Queue a new e-mail message for sending after (n) seconds.

mixed
laterOn(string $queue, int $delay, string|array $view, array $data, Closure|string $callback)

Queue a new e-mail message for sending after (n) seconds on the given queue.

string
buildQueueCallable(Closure|string $callback)

Build the callable for a queued e-mail job.

void
handleQueuedMessage(Job $job, array $data)

Handle a queued e-mail message job.

Closure|string
getQueuedCallable(array $data)

Get the true callable for a queued e-mail message.

void
forceReconnection()

Force the transport to re-connect.

void
addContent(Message $message, string $view, string $plain, string $raw, array $data)

Add the content to a given message.

array
parseView(string|array $view)

Parse the given view name or array.

void
sendSwiftMessage(Swift_Message $message)

Send a Swift Message instance.

mixed
callMessageBuilder(Closure|string $callback, Message $message)

Call the provided message builder.

createMessage()

Create a new message instance.

string
getView(string $view, array $data)

Render the given view.

getViewFactory()

Get the view factory instance.

Swift_Mailer
getSwiftMailer()

Get the Swift Mailer instance.

array
failures()

Get the array of failed recipients.

void
setSwiftMailer(Swift_Mailer $swift)

Set the Swift Mailer instance.

$this
setQueue(Factory $queue)

Set the queue manager instance.

void
setContainer(Container $container)

Set the IoC container instance.

Details

void __construct(Factory $views, Swift_Mailer $swift, Dispatcher $events = null)

Create a new Mailer instance.

Parameters

Factory $views
Swift_Mailer $swift
Dispatcher $events

Return Value

void

void alwaysFrom(string $address, string|null $name = null)

Set the global from address and name.

Parameters

string $address
string|null $name

Return Value

void

void alwaysTo(string $address, string|null $name = null)

Set the global to address and name.

Parameters

string $address
string|null $name

Return Value

void

MailableMailer to(mixed $users)

Begin the process of mailing a mailable class instance.

Parameters

mixed $users

Return Value

MailableMailer

MailableMailer bcc(mixed $users)

Begin the process of mailing a mailable class instance.

Parameters

mixed $users

Return Value

MailableMailer

int raw(string $text, Closure|string $callback)

Send a new message when only a raw text part.

Parameters

string $text
Closure|string $callback

Return Value

int

void plain(string $view, array $data, mixed $callback)

Send a new message when only a plain part.

Parameters

string $view
array $data
mixed $callback

Return Value

void

void send(string|array $view, array $data = [], Closure|string $callback = null)

Send a new message using a view.

Parameters

string|array $view
array $data
Closure|string $callback

Return Value

void

mixed queue(string|array $view, array $data = [], Closure|string $callback = null, string $queue = null)

Queue a new e-mail message for sending.

Parameters

string|array $view
array $data
Closure|string $callback
string $queue

Return Value

mixed

mixed onQueue(string $queue, string|array $view, array $data, Closure|string $callback)

Queue a new e-mail message for sending on the given queue.

Parameters

string $queue
string|array $view
array $data
Closure|string $callback

Return Value

mixed

mixed queueOn(string $queue, string|array $view, array $data, Closure|string $callback)

Queue a new e-mail message for sending on the given queue.

This method didn't match rest of framework's "onQueue" phrasing. Added "onQueue".

Parameters

string $queue
string|array $view
array $data
Closure|string $callback

Return Value

mixed

mixed later(int $delay, string|array $view, array $data = [], Closure|string $callback = null, string $queue = null)

Queue a new e-mail message for sending after (n) seconds.

Parameters

int $delay
string|array $view
array $data
Closure|string $callback
string $queue

Return Value

mixed

mixed laterOn(string $queue, int $delay, string|array $view, array $data, Closure|string $callback)

Queue a new e-mail message for sending after (n) seconds on the given queue.

Parameters

string $queue
int $delay
string|array $view
array $data
Closure|string $callback

Return Value

mixed

protected string buildQueueCallable(Closure|string $callback)

Build the callable for a queued e-mail job.

Parameters

Closure|string $callback

Return Value

string

void handleQueuedMessage(Job $job, array $data)

Handle a queued e-mail message job.

Parameters

Job $job
array $data

Return Value

void

protected Closure|string getQueuedCallable(array $data)

Get the true callable for a queued e-mail message.

Parameters

array $data

Return Value

Closure|string

protected void forceReconnection()

Force the transport to re-connect.

This will prevent errors in daemon queue situations.

Return Value

void

protected void addContent(Message $message, string $view, string $plain, string $raw, array $data)

Add the content to a given message.

Parameters

Message $message
string $view
string $plain
string $raw
array $data

Return Value

void

protected array parseView(string|array $view)

Parse the given view name or array.

Parameters

string|array $view

Return Value

array

Exceptions

InvalidArgumentException

protected void sendSwiftMessage(Swift_Message $message)

Send a Swift Message instance.

Parameters

Swift_Message $message

Return Value

void

protected mixed callMessageBuilder(Closure|string $callback, Message $message)

Call the provided message builder.

Parameters

Closure|string $callback
Message $message

Return Value

mixed

Exceptions

InvalidArgumentException

protected Message createMessage()

Create a new message instance.

Return Value

Message

protected string getView(string $view, array $data)

Render the given view.

Parameters

string $view
array $data

Return Value

string

Factory getViewFactory()

Get the view factory instance.

Return Value

Factory

Swift_Mailer getSwiftMailer()

Get the Swift Mailer instance.

Return Value

Swift_Mailer

array failures()

Get the array of failed recipients.

Return Value

array

void setSwiftMailer(Swift_Mailer $swift)

Set the Swift Mailer instance.

Parameters

Swift_Mailer $swift

Return Value

void

$this setQueue(Factory $queue)

Set the queue manager instance.

Parameters

Factory $queue

Return Value

$this

void setContainer(Container $container)

Set the IoC container instance.

Parameters

Container $container

Return Value

void