Mailable
class Mailable implements Mailable, Renderable
Traits
Properties
| static protected array | $macros | The registered string macros. |
from Macroable |
| string|null | $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|null | $markdown | The Markdown template for the message (if applicable). |
|
| protected string|null | $html | The HTML to use for the message. |
|
| string|null | $view | The view to use for the message. |
|
| string|null | $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<string, null|int|string> | $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|null | $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
Apply the callback if the given "value" is (or resolves to) truthy.
Apply the callback if the given "value" is (or resolves to) falsy.
Forward a method call to the given object.
Forward a method call to the given object, returning $this if the forwarded call returned itself.
Throw a bad method call exception for the given method.
Get a configuration value from an attribute, falling back to a property.
Extract the value from an attribute instance.
Get an instance of the given attribute class from the target class or its parents.
Determine if a property declared on a child class overrides an inherited attribute.
Call the given Closure with this instance then return the instance.
Mix another object into the class.
Dynamically handle calls to the class.
Dynamically bind parameters to the message.
Deliver the queued message after (n) seconds.
Make the queued mailable job instance.
Render the mailable into a view.
Build the view for the message.
Build the Markdown view for the message.
Build the view data for the message.
Get additional meta-data to pass along with the view data.
Build the HTML view for a Markdown message.
Build the text view for a Markdown message.
Resolve the Markdown theme for this message.
Set the sender of the message.
Determine if the given recipient is set on the mailable.
Set the recipients of the message.
Determine if the given recipient is set on the mailable.
Set the recipients of the message.
Determine if the given recipient is set on the mailable.
Set the recipients of the message.
Determine if the given recipient is set on the mailable.
Set the "reply to" address of the message.
Determine if the given replyTo is set on the mailable.
Set the recipients of the message.
Convert the given recipient arguments to an array.
Convert the given recipient into an object.
Determine if the given recipient is set on the mailable.
Determine if the mailable has the given subject.
Attach multiple files to the message.
Determine if the mailable has the given attachment.
Attach a file to the message from storage.
Attach a file to the message from storage.
Determine if the mailable has the given attachment from storage.
Determine if the mailable has the given attachment from a specific storage disk.
Attach in-memory data as an attachment.
Determine if the mailable has the given data as an attachment.
Add a tag header to the message when supported by the underlying transport.
Determine if the mailable has the given tag.
Add a metadata header to the message when supported by the underlying transport.
Determine if the mailable has the given metadata.
Assert that the mailable is from the given address.
Assert that the mailable has the given recipient.
Assert that the mailable has the given recipient.
Assert that the mailable has the given recipient.
Assert that the mailable has the given recipient.
Assert that the mailable has the given "reply to" address.
Assert that the mailable has the given subject.
Assert that the given text is present in the HTML email body.
Assert that the given text is not present in the HTML email body.
Assert that the given text strings are present in order in the HTML email body.
Assert that the given text is present in the plain-text email body.
Assert that the given text is not present in the plain-text email body.
Assert that the given text strings are present in order in the plain-text email body.
Assert the mailable has no attachments.
Assert the mailable has the given attachment.
Assert the mailable has the given data as an attachment.
Assert the mailable has the given attachment from storage.
Assert the mailable has the given attachment from a specific storage disk.
Assert that the mailable has the given tag.
Assert that the mailable has the given metadata.
Render the HTML and plain-text version of the mailable into views for assertions.
Prepare the mailable instance for delivery.
Determine if the mailable will be sent by the given mailer.
Register a callback to be called with the Symfony message instance.
Register a callback to be called while building the view data.
Flush all static state.
Details
in
Conditionable at line 23
mixed
when(mixed $value = null, callable|null $callback = null, callable|null $default = null)
Apply the callback if the given "value" is (or resolves to) truthy.
in
Conditionable at line 56
mixed
unless(mixed $value = null, callable|null $callback = null, callable|null $default = null)
Apply the callback if the given "value" is (or resolves to) falsy.
in
ForwardsCalls at line 22
protected mixed
forwardCallTo(mixed $object, string $method, array $parameters)
Forward a method call to the given object.
in
ForwardsCalls at line 52
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.
in
ForwardsCalls at line 66
static protected never
throwBadMethodCallException(string $method)
Throw a bad method call exception for the given method.
in
Localizable at line 21
mixed
withLocale(string|null $locale, Closure $callback)
Run the callback with the given locale.
in
ReadsClassAttributes at line 17
protected mixed
getAttributeValue(object $target, string $attributeClass, string|null $property = null, mixed $default = null)
Get a configuration value from an attribute, falling back to a property.
in
ReadsClassAttributes at line 46
protected mixed
extractAttributeValue(object $instance)
Extract the value from an attribute instance.
in
ReadsClassAttributes at line 58
protected object|null
getAttributeInstance(object $target, string $attributeClass, ReflectionClass|null $declaringClass = null)
Get an instance of the given attribute class from the target class or its parents.
in
ReadsClassAttributes at line 74
protected bool
propertyOverridesAttribute(object $target, ReflectionClass $reflection, string|null $property, ReflectionClass $attributeDeclaringClass)
Determine if a property declared on a child class overrides an inherited attribute.
in
Tappable at line 17
mixed
tap(callable|null $callback = null)
Call the given Closure with this instance then return the instance.
in
Macroable at line 30
static void
macro(string $name, callable|object $macro)
Register a custom macro.
Macros persist in a static property for the worker lifetime and apply to every subsequent call on the macroable class.
in
Macroable at line 44
static void
mixin(object $mixin, bool $replace = true)
Mix another object into the class.
Delegates to macro() for each method; registered macros persist in a static property for the worker lifetime.
in
Macroable at line 61
static bool
hasMacro(string $name)
Check if macro is registered.
in
Macroable at line 72
static void
flushMacros()
Flush the existing macros.
Clears worker-wide macros; concurrent coroutines may resolve different methods depending on timing.
in
Macroable at line 83
static mixed
__callStatic(string $method, array $parameters)
Dynamically handle calls to the class.
at line 1744
mixed
__call(string $method, array $parameters)
Dynamically bind parameters to the message.
at line 169
SentMessage|null
send(Factory|Mailer $mailer)
Send the message using the given mailer.
at line 193
mixed
queue(Factory $queue)
Queue the message for sending.
at line 222
mixed
later(DateInterval|DateTimeInterface|int $delay, Factory $queue)
Deliver the queued message after (n) seconds.
at line 250
protected mixed
newQueuedJob()
Make the queued mailable job instance.
at line 270
string
render()
Render the mailable into a view.
at line 293
protected array|string
buildView()
Build the view for the message.
at line 325
protected array
buildMarkdownView()
Build the Markdown view for the message.
at line 340
array
buildViewData()
Build the view data for the message.
at line 362
protected array
additionalMessageData()
Get additional meta-data to pass along with the view data.
at line 372
protected Closure
buildMarkdownHtml(array $viewData)
Build the HTML view for a Markdown message.
at line 384
protected Closure
buildMarkdownText(array $viewData)
Build the text view for a Markdown message.
at line 403
protected string
markdownTheme()
Resolve the Markdown theme for this message.
at line 430
protected Mailable
buildRecipients(Message $message)
Add all of the recipients to the message.
at line 462
protected Mailable
buildAttachments(Message $message)
Add all of the attachments to the message.
at line 484
protected void
buildDiskAttachments(Message $message)
Add all of the disk attachments to the message.
at line 531
protected Mailable
buildMetadata(Message $message)
Add all defined metadata to the message.
at line 561
Mailable
locale(string|null $locale)
Set the locale of the message.
at line 575
Mailable
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.
at line 589
Mailable
from(array|object|string $address, string|null $name = null)
Set the sender of the message.
at line 597
bool
hasFrom(array|object|string $address, string|null $name = null)
Determine if the given recipient is set on the mailable.
at line 607
Mailable
to(array|object|string $address, string|null $name = null)
Set the recipients of the message.
at line 619
bool
hasTo(array|object|string $address, string|null $name = null)
Determine if the given recipient is set on the mailable.
at line 629
Mailable
cc(array|object|string $address, string|null $name = null)
Set the recipients of the message.
at line 637
bool
hasCc(array|object|string $address, string|null $name = null)
Determine if the given recipient is set on the mailable.
at line 647
Mailable
bcc(array|object|string $address, string|null $name = null)
Set the recipients of the message.
at line 655
bool
hasBcc(array|object|string $address, string|null $name = null)
Determine if the given recipient is set on the mailable.
at line 665
Mailable
replyTo(array|object|string $address, string|null $name = null)
Set the "reply to" address of the message.
at line 673
bool
hasReplyTo(array|object|string $address, string|null $name = null)
Determine if the given replyTo is set on the mailable.
at line 685
protected Mailable
setAddress(array|object|string $address, string|null $name = null, string $property = 'to')
Set the recipients of the message.
All recipients are stored internally as [['name' => ?, 'address' => ?]]
at line 713
protected array
addressesToArray(array|object|string $address, string|null $name)
Convert the given recipient arguments to an array.
at line 727
protected object
normalizeRecipient(mixed $recipient)
Convert the given recipient into an object.
at line 756
protected bool
hasRecipient(array|object|string $address, string|null $name = null, string $property = 'to')
Determine if the given recipient is set on the mailable.
at line 807
Mailable
subject(string $subject)
Set the subject of the message.
at line 817
bool
hasSubject(string $subject)
Determine if the mailable has the given subject.
at line 828
Mailable
markdown(string $view, array $data = [])
Set the Markdown template for the message.
at line 841
Mailable
view(string $view, array $data = [])
Set the view and view data for the message.
at line 854
Mailable
html(string $html)
Set the rendered HTML content for the message.
at line 866
Mailable
text(string $textView, array $data = [])
Set the plain text view for the message.
at line 879
Mailable
with(array|string $key, mixed $value = null)
Set the view data for the message.
at line 895
Mailable
attach(Attachable|Attachment|string $file, array $options = [])
Attach a file to the message.
at line 918
Mailable
attachMany(array $files)
Attach multiple files to the message.
at line 934
bool
hasAttachment(Attachable|Attachment|string $file, array $options = [])
Determine if the mailable has the given attachment.
at line 988
Mailable
attachFromStorage(string $path, string|null $name = null, array $options = [])
Attach a file to the message from storage.
at line 998
Mailable
attachFromStorageDisk(string|null $disk, string $path, string|null $name = null, array $options = [])
Attach a file to the message from storage.
at line 1015
bool
hasAttachmentFromStorage(string $path, string|null $name = null, array $options = [])
Determine if the mailable has the given attachment from storage.
at line 1023
bool
hasAttachmentFromStorageDisk(string|null $disk, string $path, string|null $name = null, array $options = [])
Determine if the mailable has the given attachment from a specific storage disk.
at line 1038
Mailable
attachData(string $data, string $name, array $options = [])
Attach in-memory data as an attachment.
at line 1051
bool
hasAttachedData(string $data, string|null $name, array $options = [])
Determine if the mailable has the given data as an attachment.
at line 1065
Mailable
tag(string $value)
Add a tag header to the message when supported by the underlying transport.
at line 1075
bool
hasTag(string $value)
Determine if the mailable has the given tag.
at line 1086
Mailable
metadata(array|string $key, int|string|null $value = null)
Add a metadata header to the message when supported by the underlying transport.
at line 1100
bool
hasMetadata(string $key, int|string $value)
Determine if the mailable has the given metadata.
at line 1111
Mailable
assertFrom(array|object|string $address, string|null $name = null)
Assert that the mailable is from the given address.
at line 1131
Mailable
assertTo(array|object|string $address, string|null $name = null)
Assert that the mailable has the given recipient.
at line 1151
Mailable
assertHasTo(array|object|string $address, string|null $name = null)
Assert that the mailable has the given recipient.
at line 1161
Mailable
assertHasCc(array|object|string $address, string|null $name = null)
Assert that the mailable has the given recipient.
at line 1181
Mailable
assertHasBcc(array|object|string $address, string|null $name = null)
Assert that the mailable has the given recipient.
at line 1201
Mailable
assertHasReplyTo(array|object|string $address, string|null $name = null)
Assert that the mailable has the given "reply to" address.
at line 1256
Mailable
assertHasSubject(string $subject)
Assert that the mailable has the given subject.
at line 1276
Mailable
assertSeeInHtml(string $string, bool $escape = true)
Assert that the given text is present in the HTML email body.
at line 1296
Mailable
assertDontSeeInHtml(string $string, bool $escape = true)
Assert that the given text is not present in the HTML email body.
at line 1317
Mailable
assertSeeInOrderInHtml(array $strings, bool $escape = true)
Assert that the given text strings are present in order in the HTML email body.
at line 1335
Mailable
assertSeeInText(string $string)
Assert that the given text is present in the plain-text email body.
at line 1353
Mailable
assertDontSeeInText(string $string)
Assert that the given text is not present in the plain-text email body.
at line 1372
Mailable
assertSeeInOrderInText(array $strings)
Assert that the given text strings are present in order in the plain-text email body.
at line 1386
Mailable
assertHasNoAttachments()
Assert the mailable has no attachments.
at line 1411
Mailable
assertHasAttachment(Attachable|Attachment|string $file, array $options = [])
Assert the mailable has the given attachment.
at line 1428
Mailable
assertHasAttachedData(string $data, string $name, array $options = [])
Assert the mailable has the given data as an attachment.
at line 1445
Mailable
assertHasAttachmentFromStorage(string $path, string|null $name = null, array $options = [])
Assert the mailable has the given attachment from storage.
at line 1462
Mailable
assertHasAttachmentFromStorageDisk(string $disk, string $path, string|null $name = null, array $options = [])
Assert the mailable has the given attachment from a specific storage disk.
at line 1479
Mailable
assertHasTag(string $tag)
Assert that the mailable has the given tag.
at line 1498
Mailable
assertHasMetadata(string $key, int|string $value)
Assert that the mailable has the given metadata.
at line 1518
protected array
renderForAssertions()
Render the HTML and plain-text version of the mailable into views for assertions.
at line 1557
protected void
prepareMailableForDelivery()
Prepare the mailable instance for delivery.
at line 1689
bool
usesMailer(string $mailer)
Determine if the mailable will be sent by the given mailer.
at line 1699
Mailable
mailer(string|null $mailer)
Set the name of the mailer that should send the message.
at line 1711
Mailable
withSymfonyMessage(callable $callback)
Register a callback to be called with the Symfony message instance.
at line 1724
static void
buildViewDataUsing(callable $callback)
Register a callback to be called while building the view data.
The callback persists in a static property for the worker lifetime and runs on every Mailable render across all coroutines.
at line 1733
static void
flushState()
Flush all static state.