On this page
Mailable
class Mailable implements Mailable, Renderable (View source)
Traits
Properties
| 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. |
|
| 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|mixed | when(mixed $value, callable $callback, callable|null $default = null) Apply the callback if the given "value" is truthy. |
from Conditionable |
| $this|mixed | unless(mixed $value, callable $callback, callable|null $default = null) Apply the callback if the given "value" is falsy. |
from Conditionable |
| mixed | forwardCallTo(mixed $object, string $method, array $parameters) Forward a method call to the given object. |
from ForwardsCalls |
| mixed | forwardDecoratedCallTo(mixed $object, string $method, array $parameters) Forward a method call to the given object, returning $this if the forwarded call returned itself. |
from ForwardsCalls |
| static void | throwBadMethodCallException(string $method) Throw a bad method call exception for the given method. |
from ForwardsCalls |
| mixed | withLocale(string $locale, Closure $callback) Run the callback with the given locale. |
from Localizable |
| void | 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 the given delay. |
|
| 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. |
|
| string | buildMarkdownText(Markdown $markdown, array $data) Build the text view for a Markdown message. |
|
| $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 | 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. |
|
| 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. |
|
| $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 $file, array $options = []) Attach a file to the message. |
|
| $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. |
|
| $this | attachData(string $data, string $name, array $options = []) Attach in-memory data as an attachment. |
|
| $this | assertSeeInHtml(string $string) Assert that the given text is present in the HTML email body. |
|
| $this | assertDontSeeInHtml(string $string) Assert that the given text is not present 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. |
|
| array | renderForAssertions() Render the HTML and plain-text version of the mailable into views for assertions. |
|
| $this | mailer(string $mailer) Set the name of the mailer that should send the message. |
|
| $this | withSwiftMessage(callable $callback) Register a callback to be called with the Swift message instance. |
|
| static void | buildViewDataUsing(callable $callback) Register a callback to be called while building the view data. |
|
| $this | __call(string $method, array $parameters) Dynamically bind parameters to the message. |
Details
$this|mixed when(mixed $value, callable $callback, callable|null $default = null)
Apply the callback if the given "value" is truthy.
$this|mixed unless(mixed $value, callable $callback, callable|null $default = null)
Apply the callback if the given "value" is falsy.
protected mixed forwardCallTo(mixed $object, string $method, array $parameters)
Forward a method call to the given object.
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.
static protected void 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.
mixed queue(Factory $queue)
Queue the message for sending.
mixed later(DateTimeInterface|DateInterval|int $delay, Factory $queue)
Deliver the queued message after the given delay.
protected mixed newQueuedJob()
Make the queued mailable job instance.
string render()
Render the mailable into a view.
protected array|string buildView()
Build the view for the message.
protected array buildMarkdownView()
Build the Markdown view for the message.
array buildViewData()
Build the view data for the message.
protected string buildMarkdownText(Markdown $markdown, array $data)
Build the text view for a Markdown message.
protected $this buildFrom(Message $message)
Add the sender to the message.
protected $this buildRecipients(Message $message)
Add all of the recipients to the message.
protected $this buildSubject(Message $message)
Set the subject for the message.
protected $this buildAttachments(Message $message)
Add all of the attachments to the message.
protected void buildDiskAttachments(Message $message)
Add all of the disk attachments to the message.
protected $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.
The value is an integer where 1 is the highest priority and 5 is the lowest.
$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.
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.
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' => ?]]
protected array addressesToArray(object|array|string $address, string|null $name)
Convert the given recipient arguments to an array.
protected object normalizeRecipient(mixed $recipient)
Convert the given recipient into an 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.
$this subject(string $subject)
Set the subject of the message.
$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 $file, array $options = [])
Attach a file to the message.
$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.
$this attachData(string $data, string $name, array $options = [])
Attach in-memory data as an attachment.
$this assertSeeInHtml(string $string)
Assert that the given text is present in the HTML email body.
$this assertDontSeeInHtml(string $string)
Assert that the given text is not present 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.
protected array renderForAssertions()
Render the HTML and plain-text version of the mailable into views for assertions.
$this mailer(string $mailer)
Set the name of the mailer that should send the message.
$this withSwiftMessage(callable $callback)
Register a callback to be called with the Swift message instance.
static void buildViewDataUsing(callable $callback)
Register a callback to be called while building the view data.
$this __call(string $method, array $parameters)
Dynamically bind parameters to the message.
© Taylor Otwell
Licensed under the MIT License.
Laravel is a trademark of Taylor Otwell.
https://laravel.com/api/8.x/Illuminate/Mail/Mailable.html