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 | $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 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 15
mixed
withLocale(string|null $locale, Closure $callback)
Run the callback with the given locale.
in
ReadsClassAttributes at line 15
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 44
protected mixed
extractAttributeValue(object $instance)
Extract the value from an attribute instance.
in
ReadsClassAttributes at line 54
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 70
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 15
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 1595
__call(string $method, array $parameters)
Dynamically bind parameters to the message.
at line 164
SentMessage|null
send(Factory|Mailer $mailer)
Send the message using the given mailer.
at line 188
mixed
queue(Factory $queue)
Queue the message for sending.
at line 217
mixed
later(DateInterval|DateTimeInterface|int $delay, Factory $queue)
Deliver the queued message after (n) seconds.
at line 245
protected mixed
newQueuedJob()
Make the queued mailable job instance.
at line 265
string
render()
Render the mailable into a view.
at line 286
protected array|string
buildView()
Build the view for the message.
at line 318
protected array
buildMarkdownView()
Build the Markdown view for the message.
at line 333
array
buildViewData()
Build the view data for the message.
at line 355
protected array
additionalMessageData()
Get additional meta-data to pass along with the view data.
at line 365
protected Closure
buildMarkdownHtml(array $viewData)
Build the HTML view for a Markdown message.
at line 377
protected Closure
buildMarkdownText(array $viewData)
Build the text view for a Markdown message.
at line 396
protected string
markdownTheme()
Resolve the Markdown theme for this message.
at line 419
protected Mailable
buildRecipients(Message $message)
Add all of the recipients to the message.
at line 447
protected Mailable
buildAttachments(Message $message)
Add all of the attachments to the message.
at line 469
protected void
buildDiskAttachments(Message $message)
Add all of the disk attachments to the message.
at line 502
protected Mailable
buildMetadata(Message $message)
Add all defined metadata to the message.
at line 528
Mailable
locale(string $locale)
Set the locale of the message.
at line 542
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 554
Mailable
from(array|object|string $address, string|null $name = null)
Set the sender of the message.
at line 562
bool
hasFrom(array|object|string $address, string|null $name = null)
Determine if the given recipient is set on the mailable.
at line 570
Mailable
to(array|object|string $address, string|null $name = null)
Set the recipients of the message.
at line 582
bool
hasTo(array|object|string $address, string|null $name = null)
Determine if the given recipient is set on the mailable.
at line 590
Mailable
cc(array|object|string $address, string|null $name = null)
Set the recipients of the message.
at line 598
bool
hasCc(array|object|string $address, string|null $name = null)
Determine if the given recipient is set on the mailable.
at line 606
Mailable
bcc(array|object|string $address, string|null $name = null)
Set the recipients of the message.
at line 614
bool
hasBcc(array|object|string $address, string|null $name = null)
Determine if the given recipient is set on the mailable.
at line 622
Mailable
replyTo(array|object|string $address, string|null $name = null)
Set the "reply to" address of the message.
at line 630
bool
hasReplyTo(array|object|string $address, string|null $name = null)
Determine if the given replyTo is set on the mailable.
at line 640
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 668
protected array
addressesToArray(array|object|string $address, string|null $name)
Convert the given recipient arguments to an array.
at line 682
protected object
normalizeRecipient(mixed $recipient)
Convert the given recipient into an object.
at line 711
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 758
Mailable
subject(string $subject)
Set the subject of the message.
at line 768
bool
hasSubject(string $subject)
Determine if the mailable has the given subject.
at line 777
Mailable
markdown(string $view, array $data = [])
Set the Markdown template for the message.
at line 788
Mailable
view(string $view, array $data = [])
Set the view and view data for the message.
at line 799
Mailable
html(string $html)
Set the rendered HTML content for the message.
at line 809
Mailable
text(string $textView, array $data = [])
Set the plain text view for the message.
at line 820
Mailable
with(array|string $key, mixed $value = null)
Set the view data for the message.
at line 834
Mailable
attach(Attachable|Attachment|string $file, array $options = [])
Attach a file to the message.
at line 855
Mailable
attachMany(array $files)
Attach multiple files to the message.
at line 871
bool
hasAttachment(Attachable|Attachment|string $file, array $options = [])
Determine if the mailable has the given attachment.
at line 924
Mailable
attachFromStorage(string $path, string|null $name = null, array $options = [])
Attach a file to the message from storage.
at line 932
Mailable
attachFromStorageDisk(string|null $disk, string $path, string|null $name = null, array $options = [])
Attach a file to the message from storage.
at line 949
bool
hasAttachmentFromStorage(string $path, string|null $name = null, array $options = [])
Determine if the mailable has the given attachment from storage.
at line 957
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 970
Mailable
attachData(string $data, string $name, array $options = [])
Attach in-memory data as an attachment.
at line 984
bool
hasAttachedData(string $data, string|null $name, array $options = [])
Determine if the mailable has the given data as an attachment.
at line 996
Mailable
tag(string $value)
Add a tag header to the message when supported by the underlying transport.
at line 1006
bool
hasTag(string $value)
Determine if the mailable has the given tag.
at line 1015
Mailable
metadata(array|string $key, string|null $value = null)
Add a metadata header to the message when supported by the underlying transport.
at line 1029
bool
hasMetadata(string $key, int|string $value)
Determine if the mailable has the given metadata.
at line 1038
Mailable
assertFrom(array|object|string $address, string|null $name = null)
Assert that the mailable is from the given address.
at line 1056
Mailable
assertTo(array|object|string $address, string|null $name = null)
Assert that the mailable has the given recipient.
at line 1074
Mailable
assertHasTo(array|object|string $address, string|null $name = null)
Assert that the mailable has the given recipient.
at line 1082
Mailable
assertHasCc(array|object|string $address, string|null $name = null)
Assert that the mailable has the given recipient.
at line 1100
Mailable
assertHasBcc(array|object|string $address, string|null $name = null)
Assert that the mailable has the given recipient.
at line 1118
Mailable
assertHasReplyTo(array|object|string $address, string|null $name = null)
Assert that the mailable has the given "reply to" address.
at line 1171
Mailable
assertHasSubject(string $subject)
Assert that the mailable has the given subject.
at line 1186
Mailable
assertSeeInHtml(string $string, bool $escape = true)
Assert that the given text is present in the HTML email body.
at line 1204
Mailable
assertDontSeeInHtml(string $string, bool $escape = true)
Assert that the given text is not present in the HTML email body.
at line 1222
Mailable
assertSeeInOrderInHtml(array $strings, bool $escape = true)
Assert that the given text strings are present in order in the HTML email body.
at line 1238
Mailable
assertSeeInText(string $string)
Assert that the given text is present in the plain-text email body.
at line 1254
Mailable
assertDontSeeInText(string $string)
Assert that the given text is not present in the plain-text email body.
at line 1270
Mailable
assertSeeInOrderInText(array $strings)
Assert that the given text strings are present in order in the plain-text email body.
at line 1282
Mailable
assertHasAttachment(Attachable|Attachment|string $file, array $options = [])
Assert the mailable has the given attachment.
at line 1297
Mailable
assertHasAttachedData(string $data, string $name, array $options = [])
Assert the mailable has the given data as an attachment.
at line 1312
Mailable
assertHasAttachmentFromStorage(string $path, string|null $name = null, array $options = [])
Assert the mailable has the given attachment from storage.
at line 1327
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 1342
Mailable
assertHasTag(string $tag)
Assert that the mailable has the given tag.
at line 1357
Mailable
assertHasMetadata(string $key, string $value)
Assert that the mailable has the given metadata.
at line 1374
protected array
renderForAssertions()
Render the HTML and plain-text version of the mailable into views for assertions.
at line 1412
protected void
prepareMailableForDelivery()
Prepare the mailable instance for delivery.
at line 1545
bool
usesMailer(string $mailer)
Determine if the mailable will be sent by the given mailer.
at line 1553
Mailable
mailer(string|null $mailer)
Set the name of the mailer that should send the message.
at line 1563
Mailable
withSymfonyMessage(callable $callback)
Register a callback to be called with the Symfony message instance.
at line 1576
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 1584
static void
flushState()
Flush all static state.