class Illuminate / Mail / Mailable
You're browsing the documentation for an upcoming version of Laravel. The documentation and features of this release are subject to change.

Mailable

Implements

Uses

Properties

public

$locale string

The locale of the message.

Default: null
public

$from array

The person the message is from.

Default: []
public

$to array

The "to" recipients of the message.

Default: []
public

$cc array

The "cc" recipients of the message.

Default: []
public

$bcc array

The "bcc" recipients of the message.

Default: []
public

$replyTo array

The "reply to" recipients of the message.

Default: []
public

$subject string

The subject of the message.

Default: null
public

$markdown string

The Markdown template for the message (if applicable).

Default: null
protected

$html string

The HTML to use for the message.

Default: null
public

$view string

The view to use for the message.

Default: null
public

$textView string

The plain text view to use for the message.

Default: null
public

$viewData array

The view data for the message.

Default: []
public

$attachments array

The attachments for the message.

Default: []
public

$rawAttachments array

The raw attachments for the message.

Default: []
public

$diskAttachments array

The attachments from a storage disk.

Default: []
protected

$tags array

The tags for the message.

Default: []
protected

$metadata array

The metadata for the message.

Default: []
public

$callbacks array

The callbacks for the message.

Default: []
public

$theme string|null

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

Default: null
public

$mailer string

The name of the mailer that should send the message.

Default: null
protected

$assertionableRenderStrings array

The rendered mailable views for testing / assertions.

Default: null
public static

$viewDataCallback callable

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

Default: null

Methods

public

send ( $mailer ) : SentMessage |null

Send the message using the given mailer.

Parameters

public

queue ( Factory $queue ) : mixed

Queue the message for sending.

Parameters

public

later ( $delay , Factory $queue ) : mixed

Deliver the queued message after (n) seconds.

Parameters

protected

newQueuedJob ( ) : mixed

Make the queued mailable job instance.

public

render ( ) : string

Render the mailable into a view.

protected

buildView ( ) : array|string

Build the view for the message.

protected

buildMarkdownView ( ) : array

Build the Markdown view for the message.

public

buildViewData ( ) : array

Build the view data for the message.

protected

buildMarkdownHtml ( $viewData ) : Closure

Build the HTML view for a Markdown message.

Parameters

  • $viewData array
protected

buildMarkdownText ( $viewData ) : Closure

Build the text view for a Markdown message.

Parameters

  • $viewData array
protected

markdownRenderer ( ) : Markdown

Resolves a Markdown instance with the mail's theme.

protected

buildFrom ( $message ) : $this

Add the sender to the message.

Parameters

protected

buildRecipients ( $message ) : $this

Add all of the recipients to the message.

Parameters

protected

buildSubject ( $message ) : $this

Set the subject for the message.

Parameters

protected

buildAttachments ( $message ) : $this

Add all of the attachments to the message.

Parameters

protected

buildDiskAttachments ( $message ) : void

Add all of the disk attachments to the message.

Parameters

protected

buildTags ( $message ) : $this

Add all defined tags to the message.

Parameters

protected

buildMetadata ( $message ) : $this

Add all defined metadata to the message.

Parameters

protected

runCallbacks ( $message ) : $this

Run the callbacks for the message.

Parameters

public

locale ( $locale ) : $this

Set the locale of the message.

Parameters

  • $locale string
public

priority ( $level ) : $this

Set the priority of this message.

Parameters

  • $level int
public

from ( $address , $name ) : $this

Set the sender of the message.

Parameters

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

hasFrom ( $address , $name ) : bool

Determine if the given recipient is set on the mailable.

Parameters

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

to ( $address , $name ) : $this

Set the recipients of the message.

Parameters

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

hasTo ( $address , $name ) : bool

Determine if the given recipient is set on the mailable.

Parameters

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

cc ( $address , $name ) : $this

Set the recipients of the message.

Parameters

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

hasCc ( $address , $name ) : bool

Determine if the given recipient is set on the mailable.

Parameters

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

bcc ( $address , $name ) : $this

Set the recipients of the message.

Parameters

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

hasBcc ( $address , $name ) : bool

Determine if the given recipient is set on the mailable.

Parameters

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

replyTo ( $address , $name ) : $this

Set the "reply to" address of the message.

Parameters

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

hasReplyTo ( $address , $name ) : bool

Determine if the given replyTo is set on the mailable.

Parameters

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

setAddress ( $address , $name , $property ) : $this

Set the recipients of the message.

Parameters

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

addressesToArray ( $address , $name ) : array

Convert the given recipient arguments to an array.

Parameters

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

normalizeRecipient ( $recipient ) : object

Convert the given recipient into an object.

Parameters

  • $recipient mixed
protected

hasRecipient ( $address , $name , $property ) : bool

Determine if the given recipient is set on the mailable.

Parameters

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

hasEnvelopeRecipient ( $address , $name , $property ) : bool

Determine if the mailable "envelope" method defines a recipient.

Parameters

  • $address string
  • $name string|null
  • $property string
public

subject ( $subject ) : $this

Set the subject of the message.

Parameters

  • $subject string
public

hasSubject ( $subject ) : bool

Determine if the mailable has the given subject.

Parameters

  • $subject string
public

markdown ( $view , array $data ) : $this

Set the Markdown template for the message.

Parameters

  • $view string
  • $data array
public

view ( $view , array $data ) : $this

Set the view and view data for the message.

Parameters

  • $view string
  • $data array
public

html ( $html ) : $this

Set the rendered HTML content for the message.

Parameters

  • $html string
public

text ( $textView , array $data ) : $this

Set the plain text view for the message.

Parameters

  • $textView string
  • $data array
public

with ( $key , $value ) : $this

Set the view data for the message.

Parameters

  • $key string|array
  • $value mixed
public

attach ( $file , array $options ) : $this

Attach a file to the message.

Parameters

public

attachMany ( $files ) : $this

Attach multiple files to the message.

Parameters

  • $files array
public

hasAttachment ( $file , array $options ) : bool

Determine if the mailable has the given attachment.

Parameters

private

hasEnvelopeAttachment ( $attachment , $options ) : bool

Determine if the mailable has the given envelope attachment.

Parameters

public

attachFromStorage ( $path , $name , array $options ) : $this

Attach a file to the message from storage.

Parameters

  • $path string
  • $name string|null
  • $options array
public

attachFromStorageDisk ( $disk , $path , $name , array $options ) : $this

Attach a file to the message from storage.

Parameters

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

hasAttachmentFromStorage ( $path , $name , array $options ) : bool

Determine if the mailable has the given attachment from storage.

Parameters

  • $path string
  • $name string|null
  • $options array
public

hasAttachmentFromStorageDisk ( $disk , $path , $name , array $options ) : bool

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

Parameters

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

attachData ( $data , $name , array $options ) : $this

Attach in-memory data as an attachment.

Parameters

  • $data string
  • $name string
  • $options array
public

hasAttachedData ( $data , $name , array $options ) : bool

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

Parameters

  • $data string
  • $name string
  • $options array
public

tag ( $value ) : $this

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

Parameters

  • $value string
public

hasTag ( $value ) : bool

Determine if the mailable has the given tag.

Parameters

  • $value string
public

metadata ( $key , $value ) : $this

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

Parameters

  • $key string
  • $value string
public

hasMetadata ( $key , $value ) : bool

Determine if the mailable has the given metadata.

Parameters

  • $key string
  • $value string
public

assertFrom ( $address , $name ) : $this

Assert that the mailable is from the given address.

Parameters

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

assertTo ( $address , $name ) : $this

Assert that the mailable has the given recipient.

Parameters

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

assertHasTo ( $address , $name ) : $this

Assert that the mailable has the given recipient.

Parameters

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

assertHasCc ( $address , $name ) : $this

Assert that the mailable has the given recipient.

Parameters

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

assertHasBcc ( $address , $name ) : $this

Assert that the mailable has the given recipient.

Parameters

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

assertHasReplyTo ( $address , $name ) : $this

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

Parameters

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

formatAssertionRecipient ( $address , $name ) : string

Format the mailable recipient for display in an assertion message.

Parameters

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

assertHasSubject ( $subject ) : $this

Assert that the mailable has the given subject.

Parameters

  • $subject string
public

assertSeeInHtml ( $string , $escape ) : $this

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

Parameters

  • $string string
  • $escape bool
public

assertDontSeeInHtml ( $string , $escape ) : $this

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

Parameters

  • $string string
  • $escape bool
public

assertSeeInOrderInHtml ( $strings , $escape ) : $this

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

Parameters

  • $strings array
  • $escape bool
public

assertSeeInText ( $string ) : $this

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

Parameters

  • $string string
public

assertDontSeeInText ( $string ) : $this

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

Parameters

  • $string string
public

assertSeeInOrderInText ( $strings ) : $this

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

Parameters

  • $strings array
public

assertHasAttachment ( $file , array $options ) : $this

Assert the mailable has the given attachment.

Parameters

public

assertHasAttachedData ( $data , $name , array $options ) : $this

Assert the mailable has the given data as an attachment.

Parameters

  • $data string
  • $name string
  • $options array
public

assertHasAttachmentFromStorage ( $path , $name , array $options ) : $this

Assert the mailable has the given attachment from storage.

Parameters

  • $path string
  • $name string|null
  • $options array
public

assertHasAttachmentFromStorageDisk ( $disk , $path , $name , array $options ) : $this

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

Parameters

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

assertHasTag ( $tag ) : $this

Assert that the mailable has the given tag.

Parameters

  • $tag string
public

assertHasMetadata ( $key , $value ) : $this

Assert that the mailable has the given metadata.

Parameters

  • $key string
  • $value string
protected

renderForAssertions ( ) : array

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

protected

prepareMailableForDelivery ( ) : void

Prepare the mailable instance for delivery.

private

ensureHeadersAreHydrated ( ) : void

Ensure the mailable's headers are hydrated from the "headers" method.

private

ensureEnvelopeIsHydrated ( ) : void

Ensure the mailable's "envelope" data is hydrated from the "envelope" method.

private

ensureContentIsHydrated ( ) : void

Ensure the mailable's content is hydrated from the "content" method.

private

ensureAttachmentsAreHydrated ( ) : void

Ensure the mailable's attachments are hydrated from the "attachments" method.

public

mailer ( $mailer ) : $this

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

Parameters

  • $mailer string
public

withSymfonyMessage ( $callback ) : $this

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

Parameters

  • $callback callable
public static

buildViewDataUsing ( callable $callback ) : void

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

Parameters

  • $callback callable
public

__call ( $method , $parameters ) : $this

Dynamically bind parameters to the message.

Parameters

  • $method string
  • $parameters array