class Mailer implements Mailer, MailQueue

Traits

Properties

static protected array $macros

The registered string macros.

from  Macroable
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 $replyTo

The global reply-to address and name.

protected array $to

The global to address and name.

protected Queue $queue

The queue implementation.

protected array $failedRecipients

Array of failed recipients.

Methods

static void
macro(string $name, callable $macro)

Register a custom macro.

static bool
hasMacro(string $name)

Checks if macro is registered.

static mixed
__callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

mixed
__call(string $method, array $parameters)

Dynamically handle calls to the class.

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
alwaysReplyTo(string $address, string|null $name = null)

Set the global reply-to 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
sendMailable(Mailable $mailable)

Send the given mailable.

array
parseView(string|array $view)

Parse the given view name or array.

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

Add the content to a given message.

string
renderView(string $view, array $data)

Render the given view.

void
setGlobalTo(Message $message)

Set the global "to" address on the given message.

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.

createMessage()

Create a new message instance.

void
sendSwiftMessage(Swift_Message $message)

Send a Swift Message instance.

bool
shouldSendMessage(Swift_Message $message)

Determines if the message can be sent.

void
dispatchSentEvent(Message $message)

Dispatch the message sent event.

void
forceReconnection()

Force the transport to re-connect.

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.

Details

in Macroable at line 24
static void macro(string $name, callable $macro)

Register a custom macro.

Parameters

string $name
callable $macro

Return Value

void

in Macroable at line 35
static bool hasMacro(string $name)

Checks if macro is registered.

Parameters

string $name

Return Value

bool

in Macroable at line 49
static mixed __callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

in Macroable at line 71
mixed __call(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

at line 86
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

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

Set the global from address and name.

Parameters

string $address
string|null $name

Return Value

void

at line 112
void alwaysReplyTo(string $address, string|null $name = null)

Set the global reply-to address and name.

Parameters

string $address
string|null $name

Return Value

void

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

Set the global to address and name.

Parameters

string $address
string|null $name

Return Value

void

at line 135
PendingMail to(mixed $users)

Begin the process of mailing a mailable class instance.

Parameters

mixed $users

Return Value

PendingMail

at line 146
PendingMail bcc(mixed $users)

Begin the process of mailing a mailable class instance.

Parameters

mixed $users

Return Value

PendingMail

at line 158
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

at line 171
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

at line 184
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

at line 229
protected mixed sendMailable(Mailable $mailable)

Send the given mailable.

Parameters

Mailable $mailable

Return Value

mixed

at line 243
protected array parseView(string|array $view)

Parse the given view name or array.

Parameters

string|array $view

Return Value

array

Exceptions

InvalidArgumentException

at line 280
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

at line 306
protected string renderView(string $view, array $data)

Render the given view.

Parameters

string $view
array $data

Return Value

string

at line 319
protected void setGlobalTo(Message $message)

Set the global "to" address on the given message.

Parameters

Message $message

Return Value

void

at line 335
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

at line 353
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

at line 369
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

at line 384
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

at line 403
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

at line 413
protected Message createMessage()

Create a new message instance.

Return Value

Message

at line 440
protected void sendSwiftMessage(Swift_Message $message)

Send a Swift Message instance.

Parameters

Swift_Message $message

Return Value

void

at line 455
protected bool shouldSendMessage(Swift_Message $message)

Determines if the message can be sent.

Parameters

Swift_Message $message

Return Value

bool

at line 472
protected void dispatchSentEvent(Message $message)

Dispatch the message sent event.

Parameters

Message $message

Return Value

void

at line 488
protected void forceReconnection()

Force the transport to re-connect.

This will prevent errors in daemon queue situations.

Return Value

void

at line 498
Factory getViewFactory()

Get the view factory instance.

Return Value

Factory

at line 508
Swift_Mailer getSwiftMailer()

Get the Swift Mailer instance.

Return Value

Swift_Mailer

at line 518
array failures()

Get the array of failed recipients.

Return Value

array

at line 529
void setSwiftMailer(Swift_Mailer $swift)

Set the Swift Mailer instance.

Parameters

Swift_Mailer $swift

Return Value

void

at line 540
$this setQueue(Factory $queue)

Set the queue manager instance.

Parameters

Factory $queue

Return Value

$this