class Mailable implements Mailable, Renderable (View source)

Traits

Properties

static protected array $macros

The registered string macros.

from  Macroable
string $locale

The locale of the message.

array $from

The person the message is from.

array $to

The "to" recipients of the message.

array $cc

The "cc" recipients of the message.

array $bcc

The "bcc" recipients of the message.

array $replyTo

The "reply to" recipients of the message.

string $subject

The subject of the message.

string $markdown

The Markdown template for the message (if applicable).

protected string $html

The HTML to use for the message.

string $view

The view to use for the message.

string $textView

The plain text view to use for the message.

array $viewData

The view data for the message.

array $attachments

The attachments for the message.

array $rawAttachments

The raw attachments for the message.

array $diskAttachments

The attachments from a storage disk.

protected array $tags

The tags for the message.

protected array $metadata

The metadata for the message.

array $callbacks

The callbacks for the message.

string|null $theme

The name of the theme that should be used when formatting the message.

string $mailer

The name of the mailer that should send the message.

protected array $assertionableRenderStrings

The rendered mailable views for testing / assertions.

static callable $viewDataCallback

The callback that should be invoked while building the view data.

Methods

$this|TWhenReturnType
when($value = null, callable|null $callback = null, callable|null $default = null)

Apply the callback if the given "value" is (or resolves to) truthy.

$this|TUnlessReturnType
unless($value = null, callable|null $callback = null, callable|null $default = null)

Apply the callback if the given "value" is (or resolves to) falsy.

mixed
forwardCallTo(mixed $object, string $method, array $parameters)

Forward a method call to the given object.

mixed
forwardDecoratedCallTo(mixed $object, string $method, array $parameters)

Forward a method call to the given object, returning $this if the forwarded call returned itself.

static never
throwBadMethodCallException(string $method)

Throw a bad method call exception for the given method.

mixed
withLocale(string $locale, Closure $callback)

Run the callback with the given locale.

tap($callback = null)

Call the given Closure with this instance then return the instance.

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

$this
__call(string $method, array $parameters)

Dynamically bind parameters to the message.

send(Factory|Mailer $mailer)

Send the message using the given mailer.

mixed
queue(Factory $queue)

Queue the message for sending.

mixed
later(DateTimeInterface|DateInterval|int $delay, Factory $queue)

Deliver the queued message after (n) seconds.

mixed
newQueuedJob()

Make the queued mailable job instance.

string
render()

Render the mailable into a view.

array|string
buildView()

Build the view for the message.

array
buildMarkdownView()

Build the Markdown view for the message.

array
buildViewData()

Build the view data for the message.

array
additionalMessageData()

Get additional meta-data to pass along with the view data.

buildMarkdownHtml(array $viewData)

Build the HTML view for a Markdown message.

buildMarkdownText(array $viewData)

Build the text view for a Markdown message.

markdownRenderer()

Resolves a Markdown instance with the mail's theme.

$this
buildFrom(Message $message)

Add the sender to the message.

$this
buildRecipients(Message $message)

Add all of the recipients to the message.

$this
buildSubject(Message $message)

Set the subject for the message.

$this
buildAttachments(Message $message)

Add all of the attachments to the message.

void
buildDiskAttachments(Message $message)

Add all of the disk attachments to the message.

$this
buildTags(Message $message)

Add all defined tags to the message.

$this
buildMetadata(Message $message)

Add all defined metadata to the message.

$this
runCallbacks(Message $message)

Run the callbacks for the message.

$this
locale(string $locale)

Set the locale of the message.

$this
priority(int $level = 3)

Set the priority of this message.

$this
from(object|array|string $address, string|null $name = null)

Set the sender of the message.

bool
hasFrom(object|array|string $address, string|null $name = null)

Determine if the given recipient is set on the mailable.

$this
to(object|array|string $address, string|null $name = null)

Set the recipients of the message.

bool
hasTo(object|array|string $address, string|null $name = null)

Determine if the given recipient is set on the mailable.

cc(object|array|string $address, string|null $name = null)

Set the recipients of the message.

bool
hasCc(object|array|string $address, string|null $name = null)

Determine if the given recipient is set on the mailable.

$this
bcc(object|array|string $address, string|null $name = null)

Set the recipients of the message.

bool
hasBcc(object|array|string $address, string|null $name = null)

Determine if the given recipient is set on the mailable.

$this
replyTo(object|array|string $address, string|null $name = null)

Set the "reply to" address of the message.

bool
hasReplyTo(object|array|string $address, string|null $name = null)

Determine if the given replyTo is set on the mailable.

$this
setAddress(object|array|string $address, string|null $name = null, string $property = 'to')

Set the recipients of the message.

array
addressesToArray(object|array|string $address, string|null $name)

Convert the given recipient arguments to an array.

object
normalizeRecipient(mixed $recipient)

Convert the given recipient into an object.

bool
hasRecipient(object|array|string $address, string|null $name = null, string $property = 'to')

Determine if the given recipient is set on the mailable.

$this
subject(string $subject)

Set the subject of the message.

bool
hasSubject(string $subject)

Determine if the mailable has the given subject.

$this
markdown(string $view, array $data = [])

Set the Markdown template for the message.

$this
view(string $view, array $data = [])

Set the view and view data for the message.

$this
html(string $html)

Set the rendered HTML content for the message.

$this
text(string $textView, array $data = [])

Set the plain text view for the message.

$this
with(string|array $key, mixed $value = null)

Set the view data for the message.

$this
attach(string|Attachable|Attachment $file, array $options = [])

Attach a file to the message.

$this
attachMany(array $files)

Attach multiple files to the message.

bool
hasAttachment(string|Attachable|Attachment $file, array $options = [])

Determine if the mailable has the given attachment.

$this
attachFromStorage(string $path, string|null $name = null, array $options = [])

Attach a file to the message from storage.

$this
attachFromStorageDisk(string $disk, string $path, string|null $name = null, array $options = [])

Attach a file to the message from storage.

bool
hasAttachmentFromStorage(string $path, string|null $name = null, array $options = [])

Determine if the mailable has the given attachment from storage.

bool
hasAttachmentFromStorageDisk(string $disk, string $path, string|null $name = null, array $options = [])

Determine if the mailable has the given attachment from a specific storage disk.

$this
attachData(string $data, string $name, array $options = [])

Attach in-memory data as an attachment.

bool
hasAttachedData(string $data, string $name, array $options = [])

Determine if the mailable has the given data as an attachment.

$this
tag(string $value)

Add a tag header to the message when supported by the underlying transport.

bool
hasTag(string $value)

Determine if the mailable has the given tag.

$this
metadata(string $key, string $value)

Add a metadata header to the message when supported by the underlying transport.

bool
hasMetadata(string $key, string $value)

Determine if the mailable has the given metadata.

$this
assertFrom(object|array|string $address, string|null $name = null)

Assert that the mailable is from the given address.

$this
assertTo(object|array|string $address, string|null $name = null)

Assert that the mailable has the given recipient.

$this
assertHasTo(object|array|string $address, string|null $name = null)

Assert that the mailable has the given recipient.

$this
assertHasCc(object|array|string $address, string|null $name = null)

Assert that the mailable has the given recipient.

$this
assertHasBcc(object|array|string $address, string|null $name = null)

Assert that the mailable has the given recipient.

$this
assertHasReplyTo(object|array|string $address, string|null $name = null)

Assert that the mailable has the given "reply to" address.

$this
assertHasSubject(string $subject)

Assert that the mailable has the given subject.

$this
assertSeeInHtml(string $string, bool $escape = true)

Assert that the given text is present in the HTML email body.

$this
assertDontSeeInHtml(string $string, bool $escape = true)

Assert that the given text is not present in the HTML email body.

$this
assertSeeInOrderInHtml(array $strings, bool $escape = true)

Assert that the given text strings are present in order in the HTML email body.

$this
assertSeeInText(string $string)

Assert that the given text is present in the plain-text email body.

$this
assertDontSeeInText(string $string)

Assert that the given text is not present in the plain-text email body.

$this
assertSeeInOrderInText(array $strings)

Assert that the given text strings are present in order in the plain-text email body.

$this
assertHasAttachment(string|Attachable|Attachment $file, array $options = [])

Assert the mailable has the given attachment.

$this
assertHasAttachedData(string $data, string $name, array $options = [])

Assert the mailable has the given data as an attachment.

$this
assertHasAttachmentFromStorage(string $path, string|null $name = null, array $options = [])

Assert the mailable has the given attachment from storage.

$this
assertHasAttachmentFromStorageDisk(string $disk, string $path, string|null $name = null, array $options = [])

Assert the mailable has the given attachment from a specific storage disk.

$this
assertHasTag(string $tag)

Assert that the mailable has the given tag.

$this
assertHasMetadata(string $key, string $value)

Assert that the mailable has the given metadata.

array
renderForAssertions()

Render the HTML and plain-text version of the mailable into views for assertions.

void
prepareMailableForDelivery()

Prepare the mailable instance for delivery.

$this
mailer(string $mailer)

Set the name of the mailer that should send the message.

$this
withSymfonyMessage(callable $callback)

Register a callback to be called with the Symfony message instance.

static void
buildViewDataUsing(callable $callback)

Register a callback to be called while building the view data.

Details

$this|TWhenReturnType when($value = null, callable|null $callback = null, callable|null $default = null)

Apply the callback if the given "value" is (or resolves to) truthy.

Parameters

$value
callable|null $callback
callable|null $default

Return Value

$this|TWhenReturnType

$this|TUnlessReturnType unless($value = null, callable|null $callback = null, callable|null $default = null)

Apply the callback if the given "value" is (or resolves to) falsy.

Parameters

$value
callable|null $callback
callable|null $default

Return Value

$this|TUnlessReturnType

protected mixed forwardCallTo(mixed $object, string $method, array $parameters)

Forward a method call to the given object.

Parameters

mixed $object
string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

protected mixed forwardDecoratedCallTo(mixed $object, string $method, array $parameters)

Forward a method call to the given object, returning $this if the forwarded call returned itself.

Parameters

mixed $object
string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

static protected never throwBadMethodCallException(string $method)

Throw a bad method call exception for the given method.

Parameters

string $method

Return Value

never

Exceptions

BadMethodCallException

mixed withLocale(string $locale, Closure $callback)

Run the callback with the given locale.

Parameters

string $locale
Closure $callback

Return Value

mixed

tap($callback = null)

Call the given Closure with this instance then return the instance.

Parameters

$callback

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

$this __call(string $method, array $parameters)

Dynamically bind parameters to the message.

Parameters

string $method
array $parameters

Return Value

$this

Exceptions

BadMethodCallException

SentMessage|null send(Factory|Mailer $mailer)

Send the message using the given mailer.

Parameters

Factory|Mailer $mailer

Return Value

SentMessage|null

mixed queue(Factory $queue)

Queue the message for sending.

Parameters

Factory $queue

Return Value

mixed

mixed later(DateTimeInterface|DateInterval|int $delay, Factory $queue)

Deliver the queued message after (n) seconds.

Parameters

DateTimeInterface|DateInterval|int $delay
Factory $queue

Return Value

mixed

protected mixed newQueuedJob()

Make the queued mailable job instance.

Return Value

mixed

string render()

Render the mailable into a view.

Return Value

string

Exceptions

ReflectionException

protected array|string buildView()

Build the view for the message.

Return Value

array|string

Exceptions

ReflectionException

protected array buildMarkdownView()

Build the Markdown view for the message.

Return Value

array

Exceptions

ReflectionException

array buildViewData()

Build the view data for the message.

Return Value

array

Exceptions

ReflectionException

protected array additionalMessageData()

Get additional meta-data to pass along with the view data.

Return Value

array

protected Closure buildMarkdownHtml(array $viewData)

Build the HTML view for a Markdown message.

Parameters

array $viewData

Return Value

Closure

protected Closure buildMarkdownText(array $viewData)

Build the text view for a Markdown message.

Parameters

array $viewData

Return Value

Closure

protected Markdown markdownRenderer()

Resolves a Markdown instance with the mail's theme.

Return Value

Markdown

protected $this buildFrom(Message $message)

Add the sender to the message.

Parameters

Message $message

Return Value

$this

protected $this buildRecipients(Message $message)

Add all of the recipients to the message.

Parameters

Message $message

Return Value

$this

protected $this buildSubject(Message $message)

Set the subject for the message.

Parameters

Message $message

Return Value

$this

protected $this buildAttachments(Message $message)

Add all of the attachments to the message.

Parameters

Message $message

Return Value

$this

protected void buildDiskAttachments(Message $message)

Add all of the disk attachments to the message.

Parameters

Message $message

Return Value

void

protected $this buildTags(Message $message)

Add all defined tags to the message.

Parameters

Message $message

Return Value

$this

protected $this buildMetadata(Message $message)

Add all defined metadata to the message.

Parameters

Message $message

Return Value

$this

protected $this runCallbacks(Message $message)

Run the callbacks for the message.

Parameters

Message $message

Return Value

$this

$this locale(string $locale)

Set the locale of the message.

Parameters

string $locale

Return Value

$this

$this priority(int $level = 3)

Set the priority of this message.

The value is an integer where 1 is the highest priority and 5 is the lowest.

Parameters

int $level

Return Value

$this

$this from(object|array|string $address, string|null $name = null)

Set the sender of the message.

Parameters

object|array|string $address
string|null $name

Return Value

$this

bool hasFrom(object|array|string $address, string|null $name = null)

Determine if the given recipient is set on the mailable.

Parameters

object|array|string $address
string|null $name

Return Value

bool

$this to(object|array|string $address, string|null $name = null)

Set the recipients of the message.

Parameters

object|array|string $address
string|null $name

Return Value

$this

bool hasTo(object|array|string $address, string|null $name = null)

Determine if the given recipient is set on the mailable.

Parameters

object|array|string $address
string|null $name

Return Value

bool

Mailable cc(object|array|string $address, string|null $name = null)

Set the recipients of the message.

Parameters

object|array|string $address
string|null $name

Return Value

Mailable

bool hasCc(object|array|string $address, string|null $name = null)

Determine if the given recipient is set on the mailable.

Parameters

object|array|string $address
string|null $name

Return Value

bool

$this bcc(object|array|string $address, string|null $name = null)

Set the recipients of the message.

Parameters

object|array|string $address
string|null $name

Return Value

$this

bool hasBcc(object|array|string $address, string|null $name = null)

Determine if the given recipient is set on the mailable.

Parameters

object|array|string $address
string|null $name

Return Value

bool

$this replyTo(object|array|string $address, string|null $name = null)

Set the "reply to" address of the message.

Parameters

object|array|string $address
string|null $name

Return Value

$this

bool hasReplyTo(object|array|string $address, string|null $name = null)

Determine if the given replyTo is set on the mailable.

Parameters

object|array|string $address
string|null $name

Return Value

bool

protected $this setAddress(object|array|string $address, string|null $name = null, string $property = 'to')

Set the recipients of the message.

All recipients are stored internally as [['name' => ?, 'address' => ?]]

Parameters

object|array|string $address
string|null $name
string $property

Return Value

$this

protected array addressesToArray(object|array|string $address, string|null $name)

Convert the given recipient arguments to an array.

Parameters

object|array|string $address
string|null $name

Return Value

array

protected object normalizeRecipient(mixed $recipient)

Convert the given recipient into an object.

Parameters

mixed $recipient

Return Value

object

protected bool hasRecipient(object|array|string $address, string|null $name = null, string $property = 'to')

Determine if the given recipient is set on the mailable.

Parameters

object|array|string $address
string|null $name
string $property

Return Value

bool

$this subject(string $subject)

Set the subject of the message.

Parameters

string $subject

Return Value

$this

bool hasSubject(string $subject)

Determine if the mailable has the given subject.

Parameters

string $subject

Return Value

bool

$this markdown(string $view, array $data = [])

Set the Markdown template for the message.

Parameters

string $view
array $data

Return Value

$this

$this view(string $view, array $data = [])

Set the view and view data for the message.

Parameters

string $view
array $data

Return Value

$this

$this html(string $html)

Set the rendered HTML content for the message.

Parameters

string $html

Return Value

$this

$this text(string $textView, array $data = [])

Set the plain text view for the message.

Parameters

string $textView
array $data

Return Value

$this

$this with(string|array $key, mixed $value = null)

Set the view data for the message.

Parameters

string|array $key
mixed $value

Return Value

$this

$this attach(string|Attachable|Attachment $file, array $options = [])

Attach a file to the message.

Parameters

string|Attachable|Attachment $file
array $options

Return Value

$this

$this attachMany(array $files)

Attach multiple files to the message.

Parameters

array $files

Return Value

$this

bool hasAttachment(string|Attachable|Attachment $file, array $options = [])

Determine if the mailable has the given attachment.

Parameters

string|Attachable|Attachment $file
array $options

Return Value

bool

$this attachFromStorage(string $path, string|null $name = null, array $options = [])

Attach a file to the message from storage.

Parameters

string $path
string|null $name
array $options

Return Value

$this

$this attachFromStorageDisk(string $disk, string $path, string|null $name = null, array $options = [])

Attach a file to the message from storage.

Parameters

string $disk
string $path
string|null $name
array $options

Return Value

$this

bool hasAttachmentFromStorage(string $path, string|null $name = null, array $options = [])

Determine if the mailable has the given attachment from storage.

Parameters

string $path
string|null $name
array $options

Return Value

bool

bool hasAttachmentFromStorageDisk(string $disk, string $path, string|null $name = null, array $options = [])

Determine if the mailable has the given attachment from a specific storage disk.

Parameters

string $disk
string $path
string|null $name
array $options

Return Value

bool

$this attachData(string $data, string $name, array $options = [])

Attach in-memory data as an attachment.

Parameters

string $data
string $name
array $options

Return Value

$this

bool hasAttachedData(string $data, string $name, array $options = [])

Determine if the mailable has the given data as an attachment.

Parameters

string $data
string $name
array $options

Return Value

bool

$this tag(string $value)

Add a tag header to the message when supported by the underlying transport.

Parameters

string $value

Return Value

$this

bool hasTag(string $value)

Determine if the mailable has the given tag.

Parameters

string $value

Return Value

bool

$this metadata(string $key, string $value)

Add a metadata header to the message when supported by the underlying transport.

Parameters

string $key
string $value

Return Value

$this

bool hasMetadata(string $key, string $value)

Determine if the mailable has the given metadata.

Parameters

string $key
string $value

Return Value

bool

$this assertFrom(object|array|string $address, string|null $name = null)

Assert that the mailable is from the given address.

Parameters

object|array|string $address
string|null $name

Return Value

$this

$this assertTo(object|array|string $address, string|null $name = null)

Assert that the mailable has the given recipient.

Parameters

object|array|string $address
string|null $name

Return Value

$this

$this assertHasTo(object|array|string $address, string|null $name = null)

Assert that the mailable has the given recipient.

Parameters

object|array|string $address
string|null $name

Return Value

$this

$this assertHasCc(object|array|string $address, string|null $name = null)

Assert that the mailable has the given recipient.

Parameters

object|array|string $address
string|null $name

Return Value

$this

$this assertHasBcc(object|array|string $address, string|null $name = null)

Assert that the mailable has the given recipient.

Parameters

object|array|string $address
string|null $name

Return Value

$this

$this assertHasReplyTo(object|array|string $address, string|null $name = null)

Assert that the mailable has the given "reply to" address.

Parameters

object|array|string $address
string|null $name

Return Value

$this

$this assertHasSubject(string $subject)

Assert that the mailable has the given subject.

Parameters

string $subject

Return Value

$this

$this assertSeeInHtml(string $string, bool $escape = true)

Assert that the given text is present in the HTML email body.

Parameters

string $string
bool $escape

Return Value

$this

$this assertDontSeeInHtml(string $string, bool $escape = true)

Assert that the given text is not present in the HTML email body.

Parameters

string $string
bool $escape

Return Value

$this

$this assertSeeInOrderInHtml(array $strings, bool $escape = true)

Assert that the given text strings are present in order in the HTML email body.

Parameters

array $strings
bool $escape

Return Value

$this

$this assertSeeInText(string $string)

Assert that the given text is present in the plain-text email body.

Parameters

string $string

Return Value

$this

$this assertDontSeeInText(string $string)

Assert that the given text is not present in the plain-text email body.

Parameters

string $string

Return Value

$this

$this assertSeeInOrderInText(array $strings)

Assert that the given text strings are present in order in the plain-text email body.

Parameters

array $strings

Return Value

$this

$this assertHasAttachment(string|Attachable|Attachment $file, array $options = [])

Assert the mailable has the given attachment.

Parameters

string|Attachable|Attachment $file
array $options

Return Value

$this

$this assertHasAttachedData(string $data, string $name, array $options = [])

Assert the mailable has the given data as an attachment.

Parameters

string $data
string $name
array $options

Return Value

$this

$this assertHasAttachmentFromStorage(string $path, string|null $name = null, array $options = [])

Assert the mailable has the given attachment from storage.

Parameters

string $path
string|null $name
array $options

Return Value

$this

$this assertHasAttachmentFromStorageDisk(string $disk, string $path, string|null $name = null, array $options = [])

Assert the mailable has the given attachment from a specific storage disk.

Parameters

string $disk
string $path
string|null $name
array $options

Return Value

$this

$this assertHasTag(string $tag)

Assert that the mailable has the given tag.

Parameters

string $tag

Return Value

$this

$this assertHasMetadata(string $key, string $value)

Assert that the mailable has the given metadata.

Parameters

string $key
string $value

Return Value

$this

protected array renderForAssertions()

Render the HTML and plain-text version of the mailable into views for assertions.

Return Value

array

Exceptions

ReflectionException

protected void prepareMailableForDelivery()

Prepare the mailable instance for delivery.

Return Value

void

$this mailer(string $mailer)

Set the name of the mailer that should send the message.

Parameters

string $mailer

Return Value

$this

$this withSymfonyMessage(callable $callback)

Register a callback to be called with the Symfony message instance.

Parameters

callable $callback

Return Value

$this

static void buildViewDataUsing(callable $callback)

Register a callback to be called while building the view data.

Parameters

callable $callback

Return Value

void