Mailer

class Mailer implements Mailer, MailQueue (View source)

Traits

Macroable

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 Factory $queue The queue factory implementation.
protected array $failedRecipients Array of failed recipients.

Methods

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

Register a custom macro.

from Macroable
static void mixin(object $mixin, bool $replace = true)

Mix another object into the class.

from Macroable
static bool hasMacro(string $name)

Checks if macro is registered.

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

Dynamically handle calls to the class.

from Macroable
mixed __call(string $method, array $parameters)

Dynamically handle calls to the class.

from Macroable
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.

PendingMail to(mixed $users)

Begin the process of mailing a mailable class instance.

PendingMail cc(mixed $users)

Begin the process of mailing a mailable class instance.

PendingMail bcc(mixed $users)

Begin the process of mailing a mailable class instance.

void html(string $html, mixed $callback)

Send a new message with only an HTML part.

void raw(string $text, mixed $callback)

Send a new message with only a raw text part.

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

Send a new message with only a plain part.

string render(string|array $view, array $data = [])

Render the given message as a view.

void send(Mailable|string|array $view, array $data = [], Closure|string|null $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 setGlobalToAndRemoveCcAndBcc(Message $message)

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

mixed queue(Mailable|string|array $view, string|null $queue = null)

Queue a new e-mail message for sending.

mixed onQueue(string $queue, Mailable $view)

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

mixed queueOn(string $queue, Mailable $view)

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

mixed later(DateTimeInterface|DateInterval|int $delay, Mailable|string|array $view, string|null $queue = null)

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

mixed laterOn(string $queue, DateTimeInterface|DateInterval|int $delay, Mailable $view)

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

Message createMessage()

Create a new message instance.

int|null sendSwiftMessage(Swift_Message $message)

Send a Swift Message instance.

bool shouldSendMessage(Swift_Message $message, array $data = [])

Determines if the message can be sent.

void dispatchSentEvent(Message $message, array $data = [])

Dispatch the message sent event.

void forceReconnection()

Force the transport to re-connect.

array failures()

Get the array of failed recipients.

Swift_Mailer getSwiftMailer()

Get the Swift Mailer instance.

Factory getViewFactory()

Get the view factory instance.

void setSwiftMailer(Swift_Mailer $swift)

Set the Swift Mailer instance.

$this setQueue(Factory $queue)

Set the queue manager instance.

Details

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

Register a custom macro.

Parameters

string $name
object|callable $macro

Return Value

void

static void mixin(object $mixin, bool $replace = true)

Mix another object into the class.

Parameters

object $mixin
bool $replace

Return Value

void

Exceptions

ReflectionException

static bool hasMacro(string $name)

Checks if macro is registered.

Parameters

string $name

Return Value

bool

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

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

mixed __call(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

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

Set the global reply-to 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

PendingMail to(mixed $users)

Begin the process of mailing a mailable class instance.

Parameters

mixed $users

Return Value

PendingMail

PendingMail cc(mixed $users)

Begin the process of mailing a mailable class instance.

Parameters

mixed $users

Return Value

PendingMail

PendingMail bcc(mixed $users)

Begin the process of mailing a mailable class instance.

Parameters

mixed $users

Return Value

PendingMail

void html(string $html, mixed $callback)

Send a new message with only an HTML part.

Parameters

string $html
mixed $callback

Return Value

void

void raw(string $text, mixed $callback)

Send a new message with only a raw text part.

Parameters

string $text
mixed $callback

Return Value

void

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

Send a new message with only a plain part.

Parameters

string $view
array $data
mixed $callback

Return Value

void

string render(string|array $view, array $data = [])

Render the given message as a view.

Parameters

string|array $view
array $data

Return Value

string

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

Send a new message using a view.

Parameters

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

Return Value

void

protected mixed sendMailable(Mailable $mailable)

Send the given mailable.

Parameters

Mailable $mailable

Return Value

mixed

protected array parseView(string|array $view)

Parse the given view name or array.

Parameters

string|array $view

Return Value

array

Exceptions

InvalidArgumentException

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 string renderView(string $view, array $data)

Render the given view.

Parameters

string $view
array $data

Return Value

string

protected void setGlobalToAndRemoveCcAndBcc(Message $message)

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

Parameters

Message $message

Return Value

void

mixed queue(Mailable|string|array $view, string|null $queue = null)

Queue a new e-mail message for sending.

Parameters

Mailable|string|array $view
string|null $queue

Return Value

mixed

Exceptions

InvalidArgumentException

mixed onQueue(string $queue, Mailable $view)

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

Parameters

string $queue
Mailable $view

Return Value

mixed

mixed queueOn(string $queue, Mailable $view)

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
Mailable $view

Return Value

mixed

mixed later(DateTimeInterface|DateInterval|int $delay, Mailable|string|array $view, string|null $queue = null)

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

Parameters

DateTimeInterface|DateInterval|int $delay
Mailable|string|array $view
string|null $queue

Return Value

mixed

Exceptions

InvalidArgumentException

mixed laterOn(string $queue, DateTimeInterface|DateInterval|int $delay, Mailable $view)

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

Parameters

string $queue
DateTimeInterface|DateInterval|int $delay
Mailable $view

Return Value

mixed

protected Message createMessage()

Create a new message instance.

Return Value

Message

protected int|null sendSwiftMessage(Swift_Message $message)

Send a Swift Message instance.

Parameters

Swift_Message $message

Return Value

int|null

protected bool shouldSendMessage(Swift_Message $message, array $data = [])

Determines if the message can be sent.

Parameters

Swift_Message $message
array $data

Return Value

bool

protected void dispatchSentEvent(Message $message, array $data = [])

Dispatch the message sent event.

Parameters

Message $message
array $data

Return Value

void

protected void forceReconnection()

Force the transport to re-connect.

This will prevent errors in daemon queue situations.

Return Value

void

array failures()

Get the array of failed recipients.

Return Value

array

Swift_Mailer getSwiftMailer()

Get the Swift Mailer instance.

Return Value

Swift_Mailer

Factory getViewFactory()

Get the view factory instance.

Return Value

Factory

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

© Taylor Otwell
Licensed under the MIT License.
Laravel is a trademark of Taylor Otwell.
https://laravel.com/api/6.x/Illuminate/Mail/Mailer.html