MailerHelper

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

Class MailerHelper

View source

# Public Methods

Method Description
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.

# 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

# 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

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;
    }
);