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.
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[]

createTransportAdapter() ​

Creates a transport adapter based on the given mail settings.

View source

Arguments ​

Returns ​

\craft\helpers\T

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

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_TRANSPORTS ​

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_TRANSPORTS,
    function(RegisterComponentTypesEvent $event) {
        $event->types[] = MyTransportType::class;
    }
);