System\Classes\MailManager

Source: ~/modules/system/classes/MailManager.php

This class manages Mail sending functions

Protected properties

protected array $callbacks

Cache of registration callbacks.

protected array $templateCache

A cache of customised mail templates.

protected array $registeredTemplates

List of registered templates in the system

protected array $registeredPartials

List of registered partials in the system

protected array $registeredLayouts

List of registered layouts in the system

protected bool $isHtmlRenderMode

Internal marker for rendering mode

protected bool $isTwigStarted

Internal marker for booting custom twig extensions.

protected static $instance

Public methods

public void __clone()

public void __wakeup()

public bool addContentToMailer(Illuminate\Mail\Message $message, string $code, array $data, bool $plainOnly=false)

This function hijacks the addContent method of the [October\Rain\Mail\Mailer](/docs/api/october/rain/mail/mailer) class, using the [mailer.beforeAddContent](/docs/api/mailer/beforeaddcontent) event.

Parameters
  • Illuminate\Mail\Message $message
  • string $code
  • array $data
  • bool $plainOnly - Add only plain text content to the message

public bool addRawContentToMailer($message, $content, $data)

Same as addContentToMailer except with raw content.

Parameters
  • $message
  • $content
  • $data

public static void forgetInstance()

Forget this singleton's instance if it exists

public static void instance()

Create a new instance of this singleton.

public array listRegisteredLayouts()

Returns a list of the registered layouts.

public array listRegisteredPartials()

Returns a list of the registered partials.

public array listRegisteredTemplates()

Returns a list of the registered templates.

public void loadRegisteredTemplates()

Loads registered mail templates from modules and plugins

public void registerCallback(callable $callback)

Registers a callback function that defines mail templates. The callback function should register templates by calling the manager's registerMailTemplates() function. Thi instance is passed to the callback function as an argument. Usage:

MailManager::registerCallback(function ($manager) {
    $manager->registerMailTemplates([...]);
});
Parameters
  • callable $callback - A callable function.

public void registerMailLayouts($definitions)

Registers mail views and manageable layouts.

Parameters
  • $definitions

public void registerMailPartials($definitions)

Registers mail views and manageable layouts.

Parameters
  • $definitions

public void registerMailTemplates($definitions)

Registers mail views and manageable templates.

Parameters
  • $definitions

public string render(string $content, array $data=array())

Render the Markdown template into HTML.

Parameters
  • string $content
  • array $data

public void renderPartial($code, $params=array())
Parameters
  • $code
  • $params

public void renderTemplate($template, $data=array())
Parameters
  • $template
  • $data

public string renderText($content $content, array $data=array())

Render the Markdown template into text.

Parameters
  • $content $content
  • array $data

public void renderTextTemplate($template, $data=array())
Parameters
  • $template
  • $data

Protected methods

protected void __construct()

Constructor.

protected void addContentToMailerInternal(Illuminate\Mail\Message $message, string $template, array $data, bool $plainOnly=false)

Internal method used to share logic between addRawContentToMailer and addContentToMailer

Parameters
  • Illuminate\Mail\Message $message
  • string $template
  • array $data
  • bool $plainOnly - Add only plain text content to the message

protected void init()

Initialize the singleton free from constructor parameters.

protected void renderTwig($content, $data=array())

Internal helper for rendering Twig

Parameters
  • $content
  • $data

protected void startTwig()

Temporarily registers mail based token parsers with Twig.

protected void stopTwig()

Indicates that we are finished with Twig.