Mailable
class Mailable implements Mailable, Renderable
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<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 28
static void
macro(string $name, callable|object $macro)
Register a custom macro.
Boot-only. Macros persist in a static property for the worker lifetime and apply to every subsequent call on the macroable class.
in
Macroable at line 41
static void
mixin(object $mixin, bool $replace = true)
Mix another object into the class.
Boot-only. Delegates to macro() for each method; registered macros persist in a static property for the worker lifetime.
in
Macroable at line 57
static bool
hasMacro(string $name)
Check if macro is registered.
in
Macroable at line 68
static void
flushMacros()
Flush the existing macros.
Boot or tests only. Clears worker-wide macros; concurrent coroutines may resolve different methods depending on timing.
in
Macroable at line 78
static mixed
__callStatic(string $method, array $parameters)
Dynamically handle calls to the class.
at line 1660
mixed
__call(string $method, array $parameters)
Dynamically bind parameters to the message.
at line 167
SentMessage|null
send(Factory|Mailer $mailer)
Send the message using the given mailer.
at line 191
mixed
queue(Factory $queue)
Queue the message for sending.
at line 220
mixed
later(DateInterval|DateTimeInterface|int $delay, Factory $queue)
Deliver the queued message after (n) seconds.
at line 248
protected mixed
newQueuedJob()
Make the queued mailable job instance.
at line 268
string
render()
Render the mailable into a view.
at line 291
protected array|string
buildView()
Build the view for the message.
at line 323
protected array
buildMarkdownView()
Build the Markdown view for the message.
at line 338
array
buildViewData()
Build the view data for the message.
at line 360
protected array
additionalMessageData()
Get additional meta-data to pass along with the view data.
at line 370
protected Closure
buildMarkdownHtml(array $viewData)
Build the HTML view for a Markdown message.
at line 382
protected Closure
buildMarkdownText(array $viewData)
Build the text view for a Markdown message.
at line 401
protected string
markdownTheme()
Resolve the Markdown theme for this message.
at line 424
protected Mailable
buildRecipients(Message $message)
Add all of the recipients to the message.
at line 452
protected Mailable
buildAttachments(Message $message)
Add all of the attachments to the message.
at line 474
protected void
buildDiskAttachments(Message $message)
Add all of the disk attachments to the message.
at line 518
protected Mailable
buildMetadata(Message $message)
Add all defined metadata to the message.
at line 546
Mailable
locale(string $locale)
Set the locale of the message.
at line 560
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 572
Mailable
from(array|object|string $address, string|null $name = null)
Set the sender of the message.
at line 580
bool
hasFrom(array|object|string $address, string|null $name = null)
Determine if the given recipient is set on the mailable.
at line 590
Mailable
to(array|object|string $address, string|null $name = null)
Set the recipients of the message.
at line 602
bool
hasTo(array|object|string $address, string|null $name = null)
Determine if the given recipient is set on the mailable.
at line 612
Mailable
cc(array|object|string $address, string|null $name = null)
Set the recipients of the message.
at line 620
bool
hasCc(array|object|string $address, string|null $name = null)
Determine if the given recipient is set on the mailable.
at line 630
Mailable
bcc(array|object|string $address, string|null $name = null)
Set the recipients of the message.
at line 638
bool
hasBcc(array|object|string $address, string|null $name = null)
Determine if the given recipient is set on the mailable.
at line 646
Mailable
replyTo(array|object|string $address, string|null $name = null)
Set the "reply to" address of the message.
at line 654
bool
hasReplyTo(array|object|string $address, string|null $name = null)
Determine if the given replyTo is set on the mailable.
at line 666
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 694
protected array
addressesToArray(array|object|string $address, string|null $name)
Convert the given recipient arguments to an array.
at line 708
protected object
normalizeRecipient(mixed $recipient)
Convert the given recipient into an object.
at line 737
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 786
Mailable
subject(string $subject)
Set the subject of the message.
at line 796
bool
hasSubject(string $subject)
Determine if the mailable has the given subject.
at line 805
Mailable
markdown(string $view, array $data = [])
Set the Markdown template for the message.
at line 816
Mailable
view(string $view, array $data = [])
Set the view and view data for the message.
at line 827
Mailable
html(string $html)
Set the rendered HTML content for the message.
at line 837
Mailable
text(string $textView, array $data = [])
Set the plain text view for the message.
at line 848
Mailable
with(array|string $key, mixed $value = null)
Set the view data for the message.
at line 862
Mailable
attach(Attachable|Attachment|string $file, array $options = [])
Attach a file to the message.
at line 883
Mailable
attachMany(array $files)
Attach multiple files to the message.
at line 899
bool
hasAttachment(Attachable|Attachment|string $file, array $options = [])
Determine if the mailable has the given attachment.
at line 951
Mailable
attachFromStorage(string $path, string|null $name = null, array $options = [])
Attach a file to the message from storage.
at line 959
Mailable
attachFromStorageDisk(string|null $disk, string $path, string|null $name = null, array $options = [])
Attach a file to the message from storage.
at line 976
bool
hasAttachmentFromStorage(string $path, string|null $name = null, array $options = [])
Determine if the mailable has the given attachment from storage.
at line 984
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 997
Mailable
attachData(string $data, string $name, array $options = [])
Attach in-memory data as an attachment.
at line 1010
bool
hasAttachedData(string $data, string|null $name, array $options = [])
Determine if the mailable has the given data as an attachment.
at line 1022
Mailable
tag(string $value)
Add a tag header to the message when supported by the underlying transport.
at line 1032
bool
hasTag(string $value)
Determine if the mailable has the given tag.
at line 1041
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 1055
bool
hasMetadata(string $key, int|string $value)
Determine if the mailable has the given metadata.
at line 1064
Mailable
assertFrom(array|object|string $address, string|null $name = null)
Assert that the mailable is from the given address.
at line 1082
Mailable
assertTo(array|object|string $address, string|null $name = null)
Assert that the mailable has the given recipient.
at line 1100
Mailable
assertHasTo(array|object|string $address, string|null $name = null)
Assert that the mailable has the given recipient.
at line 1108
Mailable
assertHasCc(array|object|string $address, string|null $name = null)
Assert that the mailable has the given recipient.
at line 1126
Mailable
assertHasBcc(array|object|string $address, string|null $name = null)
Assert that the mailable has the given recipient.
at line 1144
Mailable
assertHasReplyTo(array|object|string $address, string|null $name = null)
Assert that the mailable has the given "reply to" address.
at line 1197
Mailable
assertHasSubject(string $subject)
Assert that the mailable has the given subject.
at line 1215
Mailable
assertSeeInHtml(string $string, bool $escape = true)
Assert that the given text is present in the HTML email body.
at line 1233
Mailable
assertDontSeeInHtml(string $string, bool $escape = true)
Assert that the given text is not present in the HTML email body.
at line 1253
Mailable
assertSeeInOrderInHtml(array $strings, bool $escape = true)
Assert that the given text strings are present in order in the HTML email body.
at line 1269
Mailable
assertSeeInText(string $string)
Assert that the given text is present in the plain-text email body.
at line 1285
Mailable
assertDontSeeInText(string $string)
Assert that the given text is not present in the plain-text email body.
at line 1303
Mailable
assertSeeInOrderInText(array $strings)
Assert that the given text strings are present in order in the plain-text email body.
at line 1315
Mailable
assertHasNoAttachments()
Assert the mailable has no attachments.
at line 1340
Mailable
assertHasAttachment(Attachable|Attachment|string $file, array $options = [])
Assert the mailable has the given attachment.
at line 1355
Mailable
assertHasAttachedData(string $data, string $name, array $options = [])
Assert the mailable has the given data as an attachment.
at line 1370
Mailable
assertHasAttachmentFromStorage(string $path, string|null $name = null, array $options = [])
Assert the mailable has the given attachment from storage.
at line 1385
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 1400
Mailable
assertHasTag(string $tag)
Assert that the mailable has the given tag.
at line 1417
Mailable
assertHasMetadata(string $key, int|string $value)
Assert that the mailable has the given metadata.
at line 1437
protected array
renderForAssertions()
Render the HTML and plain-text version of the mailable into views for assertions.
at line 1476
protected void
prepareMailableForDelivery()
Prepare the mailable instance for delivery.
at line 1608
bool
usesMailer(string $mailer)
Determine if the mailable will be sent by the given mailer.
at line 1618
Mailable
mailer(string|null $mailer)
Set the name of the mailer that should send the message.
at line 1628
Mailable
withSymfonyMessage(callable $callback)
Register a callback to be called with the Symfony message instance.
at line 1641
static void
buildViewDataUsing(callable $callback)
Register a callback to be called while building the view data.
Boot-only. The callback persists in a static property for the worker lifetime and runs on every Mailable render across all coroutines.
at line 1649
static void
flushState()
Flush all static state.