Search code examples
yii2yii2-extensionyii2-module

Yii2: Override 3rd party mail views


How do we override mail view files of a 3rd party module/component?

Let's assume a module is using the following code to send an email:

Yii::$app->mailer->compose([
    'html'  => '@myvendor/mymodule/mail/email-html',
    'text'  => '@myvendor/mymodule/mail/email-text',
])
    ->setTo([$email => $name])
    ->setSubject('Hi');
    ->send();

How would we override these individual email views @myvendor/mymodule/mail/email-html and @myvendor/mymodule/mail/email-text?


Solution

  • You can override these two aliases in your config:

    'aliases' => [
        '@myvendor/mymodule/mail/email-html' => '@app/views/mail/email-html',
        '@myvendor/mymodule/mail/email-text' => '@app/views/mail/email-text',
    ],