Mailer
class Mailer implements Mailer, MailQueue
Traits
Properties
| static protected array | $macros | The registered string macros. |
from Macroable |
| protected array | $from | The global from address and name. |
|
| protected array | $replyTo | The global reply-to address and name. |
|
| protected array | $returnPath | The global return path address. |
|
| protected array | $to | The global to address and name. |
|
| protected Factory|null | $queue | The queue factory implementation. |
Methods
Mix another object into the class.
Dynamically handle calls to the class.
Dynamically handle calls to the class.
Create a new Mailer instance.
Set the global from address and name.
Set the global reply-to address and name.
Set the global return path address.
Set the global to address and name.
Begin the process of mailing a mailable class instance.
Begin the process of mailing a mailable class instance.
Begin the process of mailing a mailable class instance.
Send a new message with only an HTML part.
Send a new message with only a raw text part.
Send a new message with only a plain part.
Replace the embedded image attachments with raw, inline image data for browser rendering.
Queue a new mail message for sending after (n) seconds.
Queue a new mail message for sending after (n) seconds on the given queue.
Create a new message instance.
Send a Symfony Email instance.
Determines if the email can be sent.
Get the Symfony Transport instance.
Get the view factory instance.
Set the Symfony Transport instance.
Flush all static state.
Details
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.
in
Macroable at line 103
mixed
__call(string $method, array $parameters)
Dynamically handle calls to the class.
at line 69
__construct(string $name, Factory $views, TransportInterface $transport, Dispatcher|null $events = null)
Create a new Mailer instance.
at line 84
void
alwaysFrom(string $address, string|null $name = null)
Set the global from address and name.
Boot-only. Mutates the shared Mailer's global from; per-request use races across coroutines and applies the change to every subsequent message.
at line 96
void
alwaysReplyTo(string $address, string|null $name = null)
Set the global reply-to address and name.
Boot-only. Mutates the shared Mailer's global reply-to; per-request use races across coroutines and applies the change to every subsequent message.
at line 108
void
alwaysReturnPath(string $address)
Set the global return path address.
Boot-only. Mutates the shared Mailer's global return path; per-request use races across coroutines and applies the change to every subsequent message.
at line 120
void
alwaysTo(string $address, string|null $name = null)
Set the global to address and name.
Boot-only. Mutates the shared Mailer's global to; once set, Mailer::send() silently redirects every subsequent email across all coroutines to this address. Per-request use is never safe.
at line 128
PendingMail
to(mixed $users, string|null $name = null)
Begin the process of mailing a mailable class instance.
at line 140
PendingMail
cc(mixed $users, string|null $name = null)
Begin the process of mailing a mailable class instance.
at line 152
PendingMail
bcc(mixed $users, string|null $name = null)
Begin the process of mailing a mailable class instance.
at line 164
SentMessage|null
html(string $html, mixed $callback)
Send a new message with only an HTML part.
at line 172
SentMessage|null
raw(string $text, mixed $callback)
Send a new message with only a raw text part.
at line 180
SentMessage|null
plain(string $view, array $data, mixed $callback)
Send a new message with only a plain part.
at line 188
string
render(array|Closure|string $view, array $data = [])
Render the given message as a view.
at line 206
protected string
replaceEmbeddedAttachments(string $renderedView, array $attachments)
Replace the embedded image attachments with raw, inline image data for browser rendering.
at line 230
SentMessage|null
send(array|Mailable|string $view, array $data = [], Closure|string|null $callback = null)
Send a new message using a view.
at line 284
protected SentMessage|null
sendMailable(Mailable $mailable)
Send the given mailable.
at line 299
SentMessage|null
sendNow(array|Mailable|string $mailable, array $data = [], Closure|string|null $callback = null)
Send a new message synchronously using a view.
at line 311
protected array
parseView(array|Closure|string $view)
Parse the given view name or array.
at line 337
protected void
addContent(Message $message, Closure|Htmlable|string|null $view, Closure|Htmlable|string|null $plain, string|null $raw, array $data = [])
Add the content to a given message.
at line 355
protected string
renderView(Closure|Htmlable|string $view, array $data)
Render the given view.
at line 367
protected void
setGlobalToAndRemoveCcAndBcc(Message $message)
Set the global "to" address on the given message.
at line 382
mixed
queue(array|Mailable|string $view, string|null $queue = null)
Queue a new mail message for sending.
at line 398
mixed
onQueue(string|null $queue, Mailable $view)
Queue a new mail message for sending on the given queue.
at line 408
mixed
queueOn(string $queue, Mailable $view)
Queue a new mail message for sending on the given queue.
This method didn't match rest of framework's "onQueue" phrasing. Added "onQueue".
at line 418
mixed
later(DateInterval|DateTimeInterface|int $delay, array|Mailable|string $view, string|null $queue = null)
Queue a new mail message for sending after (n) seconds.
at line 433
mixed
laterOn(string $queue, DateInterval|DateTimeInterface|int $delay, Mailable $view)
Queue a new mail message for sending after (n) seconds on the given queue.
at line 441
protected Message
createMessage()
Create a new message instance.
at line 469
protected SentMessage|null
sendSymfonyMessage(Email $message)
Send a Symfony Email instance.
at line 480
protected bool
shouldSendMessage(Email $message, array $data = [])
Determines if the email can be sent.
at line 498
protected void
dispatchSentEvent(SentMessage $message, array $data = [])
Dispatch the message sent event.
at line 510
TransportInterface
getSymfonyTransport()
Get the Symfony Transport instance.
at line 518
Factory
getViewFactory()
Get the view factory instance.
at line 530
void
setSymfonyTransport(TransportInterface $transport)
Set the Symfony Transport instance.
Boot-only. Replaces the transport on the shared Mailer; per-request use races across coroutines and routes every other coroutine's mail through the swapped transport.
at line 541
Mailer
setQueue(Factory $queue)
Set the queue manager instance.
Boot-only. Replaces the queue factory on the shared Mailer; per-request use races across coroutines.
at line 551
static void
flushState()
Flush all static state.