Skip to content

MailerHelper ​

Type
Class
Namespace
craft\helpers
Inherits
craft\helpers\MailerHelper
Since
3.0.0

Class MailerHelper

View source

Public Methods ​

MethodDescription
allMailerTransportTypes()Returns all available mailer transport adapter classes.
createMailer()Creates a mailer component based on the given mail settings.
createTransportAdapter()Creates a transport adapter based on the given mail settings.
normalizeEmails()Normalizes To/From/CC/BCC values into an array of email addresses, or email/name pairs.
settingsReport()Returns a report of the settings used for the given Mailer instance.

allMailerTransportTypes() ​

Returns all available mailer transport adapter classes.

View source

Returns ​

string[]

createMailer() ​

DEPRECATED

Deprecated in 3.0.18. Use craft\helpers\App::mailerConfig() instead.

Creates a mailer component based on the given mail settings.

View source

Arguments ​

Returns ​

craft\mail\Mailer

createTransportAdapter() ​

Creates a transport adapter based on the given mail settings.

View source

Arguments ​

Returns ​

craft\mail\transportadapters\TransportAdapterInterface

Throws ​

normalizeEmails() ​

Since
3.5.0

Normalizes To/From/CC/BCC values into an array of email addresses, or email/name pairs.

View source

Arguments ​

Returns ​

array, null

settingsReport() ​

Since
3.5.0

Returns a report of the settings used for the given Mailer instance.

View source

Arguments ​

Returns ​

string

Events ​

EVENT_REGISTER_MAILER_TRANSPORT_TYPES ​

Type
craft\events\RegisterComponentTypesEvent

The event that is triggered when registering mailer transport adapter types.

Mailer transports must implement craft\mail\transportadapters\TransportAdapterInterface. craft\mail\transportadapters\BaseTransportAdapter provides a base implementation.


Example ​

php
use craft\events\RegisterComponentTypesEvent;
use craft\helpers\MailerHelper;
use yii\base\Event;

Event::on(MailerHelper::class,
    MailerHelper::EVENT_REGISTER_MAILER_TRANSPORT_TYPES,
    function(RegisterComponentTypesEvent $event) {
        $event->types[] = MyTransportType::class;
    }
);