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.
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 30
static void
macro(string $name, callable|object $macro)
Register a custom macro.
Macros persist in a static property for the worker lifetime and apply to every subsequent call on the macroable class.
in
Macroable at line 44
static void
mixin(object $mixin, bool $replace = true)
Mix another object into the class.
Delegates to macro() for each method; registered macros persist in a static property for the worker lifetime.
in
Macroable at line 61
static bool
hasMacro(string $name)
Check if macro is registered.
in
Macroable at line 72
static void
flushMacros()
Flush the existing macros.
Clears worker-wide macros; concurrent coroutines may resolve different methods depending on timing.
in
Macroable at line 83
static mixed
__callStatic(string $method, array $parameters)
Dynamically handle calls to the class.
in
Macroable at line 108
mixed
__call(string $method, array $parameters)
Dynamically handle calls to the class.
at line 71
__construct(string $name, Factory $views, TransportInterface $transport, Dispatcher|null $events = null)
Create a new Mailer instance.
at line 86
void
alwaysFrom(string $address, string|null $name = null)
Set the global from address and name.
Mutates the shared Mailer's global from; per-request use races across coroutines and applies the change to every subsequent message.
at line 98
void
alwaysReplyTo(string $address, string|null $name = null)
Set the global reply-to address and name.
Mutates the shared Mailer's global reply-to; per-request use races across coroutines and applies the change to every subsequent message.
at line 110
void
alwaysReturnPath(string $address)
Set the global return path address.
Mutates the shared Mailer's global return path; per-request use races across coroutines and applies the change to every subsequent message.
at line 123
void
alwaysTo(string $address, string|null $name = null)
Set the global to address and name.
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 132
PendingMail
to(mixed $users, string|null $name = null)
Begin the process of mailing a mailable class instance.
at line 144
PendingMail
cc(mixed $users, string|null $name = null)
Begin the process of mailing a mailable class instance.
at line 156
PendingMail
bcc(mixed $users, string|null $name = null)
Begin the process of mailing a mailable class instance.
at line 168
SentMessage|null
html(string $html, Closure|string $callback)
Send a new message with only an HTML part.
at line 176
SentMessage|null
raw(string $text, Closure|string $callback)
Send a new message with only a raw text part.
at line 184
SentMessage|null
plain(string $view, array $data, Closure|string $callback)
Send a new message with only a plain part.
at line 192
string
render(array|Closure|string $view, array $data = [])
Render the given message as a view.
at line 210
protected string
replaceEmbeddedAttachments(string $renderedView, array $attachments)
Replace the embedded image attachments with raw, inline image data for browser rendering.
at line 234
SentMessage|null
send(array|Mailable|string $view, array $data = [], Closure|string|null $callback = null)
Send a new message using a view.
at line 285
protected SentMessage|null
sendMailable(Mailable $mailable)
Send the given mailable.
at line 300
SentMessage|null
sendNow(array|Mailable|string $mailable, array $data = [], Closure|string|null $callback = null)
Send a new message synchronously using a view.
at line 312
protected array
parseView(array|Closure|string $view)
Parse the given view name or array.
at line 338
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 356
protected string
renderView(Closure|Htmlable|string $view, array $data)
Render the given view.
at line 368
protected void
setGlobalToAndRemoveCcAndBcc(Message $message)
Set the global "to" address on the given message.
at line 383
mixed
queue(array|Mailable|string $view, UnitEnum|string|null $queue = null)
Queue a new mail message for sending.
at line 400
mixed
onQueue(UnitEnum|string|null $queue, Mailable $view)
Queue a new mail message for sending on the given queue.
at line 410
mixed
queueOn(UnitEnum|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 420
mixed
later(DateInterval|DateTimeInterface|int $delay, array|Mailable|string $view, UnitEnum|string|null $queue = null)
Queue a new mail message for sending after (n) seconds.
at line 437
mixed
laterOn(UnitEnum|string $queue, DateInterval|DateTimeInterface|int $delay, Mailable $view)
Queue a new mail message for sending after (n) seconds on the given queue.
at line 445
protected Message
createMessage()
Create a new message instance.
at line 473
protected SentMessage|null
sendSymfonyMessage(Email $message)
Send a Symfony Email instance.
at line 486
protected bool
shouldSendMessage(Email $message, array $data = [])
Determines if the email can be sent.
at line 504
protected void
dispatchSentEvent(SentMessage $message, array $data = [])
Dispatch the message sent event.
at line 516
TransportInterface
getSymfonyTransport()
Get the Symfony Transport instance.
at line 524
Factory
getViewFactory()
Get the view factory instance.
at line 536
void
setSymfonyTransport(TransportInterface $transport)
Set the Symfony Transport instance.
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 550
Mailer
setQueue(Factory $queue)
Set the queue manager instance.
Replaces the queue factory on the shared Mailer; per-request use races across coroutines.
at line 561
static void
flushState()
Flush all static state.