MailManager
This class manages Mail sending functions
class System\Classes\MailManager
Traits
| Trait | Description |
|---|---|
Singleton
|
Singleton trait. |
Properties
protected
$callbacks
:
array
= []
Cache of registration callbacks.
protected
$isHtmlRenderMode
:
bool
= false
Internal marker for rendering mode
protected $registeredLayouts : array
List of registered layouts in the system
protected $registeredPartials : array
List of registered partials in the system
protected $registeredTemplates : array
List of registered templates in the system
protected
$templateCache
:
array
= []
A cache of customised mail templates.
Methods
public
addContentToMailer (Illuminate\Mail\Message $message, string $code, array $data, boolean $plainOnly = false)
: bool
This function hijacks the addContent method of the Winter\Storm\Mail\Mailer
class, using the mailer.beforeAddContent event.
| Property | Type | Description |
|---|---|---|
| $message | Illuminate\Mail\Message |
Illuminate\Mail\Message
|
| $code | string |
string
|
| $data | array |
array
|
| $plainOnly | boolean |
boolean
Add only plain text content to the message |
public addRawContentToMailer ($message, $content, $data) : bool
Same as addContentToMailer except with raw content.
| Property | Type | Description |
|---|---|---|
| $message | mixed |
mixed
|
| $content | mixed |
mixed
|
| $data | mixed |
mixed
|
public listRegisteredLayouts () : array
Returns a list of the registered layouts.
public listRegisteredPartials () : array
Returns a list of the registered partials.
public listRegisteredTemplates () : array
Returns a list of the registered templates.
public loadRegisteredTemplates () : void
Loads registered mail templates from modules and plugins
public registerCallback (callable $callback)
Registers a callback function that defines mail templates.
The callback function should register templates by calling the manager's registerMailTemplates() function. This instance is passed to the callback function as an argument. Usage:
MailManager::registerCallback(function ($manager) {
$manager->registerMailTemplates([...]);
});
| Property | Type | Description |
|---|---|---|
| $callback | callable |
callable
A callable function. |
public registerMailLayouts (array $definitions)
Registers mail views and manageable layouts.
| Property | Type | Description |
|---|---|---|
| $definitions | array |
array
|
public registerMailPartials (array $definitions)
Registers mail views and manageable layouts.
| Property | Type | Description |
|---|---|---|
| $definitions | array |
array
|
public registerMailTemplates (array $definitions)
Registers mail views and manageable templates.
| Property | Type | Description |
|---|---|---|
| $definitions | array |
array
|
public
render (string $content, array $data = [])
: string
Render the Markdown template into HTML.
| Property | Type | Description |
|---|---|---|
| $content | string |
string
|
| $data | array |
array
|
public
renderPartial ($code, array $params = [])
| Property | Type | Description |
|---|---|---|
| $code | mixed |
mixed
|
| $params | array |
array
|
public
renderTemplate ($template, array $data = [])
| Property | Type | Description |
|---|---|---|
| $template | mixed |
mixed
|
| $data | array |
array
|
public
renderText (mixed $content, array $data = [])
: string
Render the Markdown template into text.
| Property | Type | Description |
|---|---|---|
| $content | mixed |
mixed
|
| $data | array |
array
|
public
renderTextTemplate ($template, array $data = [])
| Property | Type | Description |
|---|---|---|
| $template | mixed |
mixed
|
| $data | array |
array
|
protected
addContentToMailerInternal (Illuminate\Mail\Message $message, string $template, array $data, boolean $plainOnly = false)
: void
Internal method used to share logic between addRawContentToMailer and addContentToMailer
| Property | Type | Description |
|---|---|---|
| $message | Illuminate\Mail\Message |
Illuminate\Mail\Message
|
| $template | string |
string
|
| $data | array |
array
|
| $plainOnly | boolean |
boolean
Add only plain text content to the message |
protected
renderTwig (string $content, array $data = [])
: string
Internal helper for rendering Twig using the mailer Twig environment
| Property | Type | Description |
|---|---|---|
| $content | string |
string
|
| $data | array |
array
|
inherited public __clone ()
inherited public __wakeup ()
inherited
public
static
final
forgetInstance ($container = null)
: void
Forget this singleton's instance if it exists
| Property | Type | Description |
|---|---|---|
| $container | mixed |
mixed
|
inherited
public
static
final
instance ($container = null)
: static
Create a new instance of this singleton.
| Property | Type | Description |
|---|---|---|
| $container | mixed |
mixed
|
inherited protected final __construct ()
Constructor.
inherited protected init ()
Initialize the singleton free from constructor parameters.