class Mailer implements Mailer, MailQueue (View source)

Traits

Properties

static protected array $macros

The registered string macros.

from  Macroable
protected string $name

The name that is configured for the mailer.

protected Factory $views

The view factory instance.

protected TransportInterface $transport

The Symfony Transport 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 $returnPath

The global return path address.

protected array $to

The global to address and name.

protected Factory $queue

The queue factory implementation.

Methods

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

Register a custom macro.

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

Mix another object into the class.

static bool
hasMacro(string $name)

Checks if macro is registered.

static void
flushMacros()

Flush the existing macros.

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(string $name, Factory $views, TransportInterface $transport, Dispatcher|null $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
alwaysReturnPath(string $address)

Set the global return path address.

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

Set the global to address and name.

to(mixed $users, string|null $name = null)

Begin the process of mailing a mailable class instance.

cc(mixed $users, string|null $name = null)

Begin the process of mailing a mailable class instance.

bcc(mixed $users, string|null $name = null)

Begin the process of mailing a mailable class instance.

html(string $html, mixed $callback)

Send a new message with only an HTML part.

raw(string $text, mixed $callback)

Send a new message with only a raw text part.

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.

string
replaceEmbeddedAttachments(string $renderedView, array $attachments)

Replace the embedded image attachments with raw, inline image data for browser rendering.

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

Send a new message using a view.

sendMailable(Mailable $mailable)

Send the given mailable.

sendNow(Mailable|string|array $mailable, array $data = [], Closure|string|null $callback = null)

Send a new message synchronously using a view.

array
parseView(Closure|array|string $view)

Parse the given view name or array.

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

Add the content to a given message.

string
renderView(Closure|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 mail message for sending.

mixed
onQueue(string $queue, Mailable $view)

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

mixed
queueOn(string $queue, Mailable $view)

Queue a new 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 mail message for sending after (n) seconds.

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

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

createMessage()

Create a new message instance.

SentMessage|null
sendSymfonyMessage(Email $message)

Send a Symfony Email instance.

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

Determines if the email can be sent.

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

Dispatch the message sent event.

TransportInterface
getSymfonyTransport()

Get the Symfony Transport instance.

getViewFactory()

Get the view factory instance.

void
setSymfonyTransport(TransportInterface $transport)

Set the Symfony Transport 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 void flushMacros()

Flush the existing macros.

Return Value

void

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(string $name, Factory $views, TransportInterface $transport, Dispatcher|null $events = null)

Create a new Mailer instance.

Parameters

string $name
Factory $views
TransportInterface $transport
Dispatcher|null $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 alwaysReturnPath(string $address)

Set the global return path address.

Parameters

string $address

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

Begin the process of mailing a mailable class instance.

Parameters

mixed $users
string|null $name

Return Value

PendingMail

PendingMail cc(mixed $users, string|null $name = null)

Begin the process of mailing a mailable class instance.

Parameters

mixed $users
string|null $name

Return Value

PendingMail

PendingMail bcc(mixed $users, string|null $name = null)

Begin the process of mailing a mailable class instance.

Parameters

mixed $users
string|null $name

Return Value

PendingMail

SentMessage|null html(string $html, mixed $callback)

Send a new message with only an HTML part.

Parameters

string $html
mixed $callback

Return Value

SentMessage|null

SentMessage|null raw(string $text, mixed $callback)

Send a new message with only a raw text part.

Parameters

string $text
mixed $callback

Return Value

SentMessage|null

SentMessage|null 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

SentMessage|null

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

Render the given message as a view.

Parameters

string|array $view
array $data

Return Value

string

protected string replaceEmbeddedAttachments(string $renderedView, array $attachments)

Replace the embedded image attachments with raw, inline image data for browser rendering.

Parameters

string $renderedView
array $attachments

Return Value

string

SentMessage|null 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

SentMessage|null

protected SentMessage|null sendMailable(Mailable $mailable)

Send the given mailable.

Parameters

Mailable $mailable

Return Value

SentMessage|null

SentMessage|null sendNow(Mailable|string|array $mailable, array $data = [], Closure|string|null $callback = null)

Send a new message synchronously using a view.

Parameters

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

Return Value

SentMessage|null

protected array parseView(Closure|array|string $view)

Parse the given view name or array.

Parameters

Closure|array|string $view

Return Value

array

Exceptions

InvalidArgumentException

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

Add the content to a given message.

Parameters

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

Return Value

void

protected string renderView(Closure|string $view, array $data)

Render the given view.

Parameters

Closure|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 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 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 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 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 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 SentMessage|null sendSymfonyMessage(Email $message)

Send a Symfony Email instance.

Parameters

Email $message

Return Value

SentMessage|null

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

Determines if the email can be sent.

Parameters

Email $message
array $data

Return Value

bool

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

Dispatch the message sent event.

Parameters

SentMessage $message
array $data

Return Value

void

TransportInterface getSymfonyTransport()

Get the Symfony Transport instance.

Return Value

TransportInterface

Factory getViewFactory()

Get the view factory instance.

Return Value

Factory

void setSymfonyTransport(TransportInterface $transport)

Set the Symfony Transport instance.

Parameters

TransportInterface $transport

Return Value

void

$this setQueue(Factory $queue)

Set the queue manager instance.

Parameters

Factory $queue

Return Value

$this