urbanindo / yii2-mail-object

这个包裹将Yii2邮件器作为对象封装

v1.0 2018-06-22 08:03 UTC

This package is auto-updated.

Last update: 2024-09-22 17:12:01 UTC


README

这封装了可以实例化的邮件对象。

Build Status

用法

使用 MailObject 创建新的邮件对象类。

例如:

class DummyMail extends MailObject
{
    protected function getSubject(): string
    {
        return 'Hello, World!';
    }

    protected function getContentParams(): array
    {
        return [
            'recipientName' => 'Jane Doe',
        ];
    }

    protected function getRecipient(): array
    {
        return [
            'jane.doe@example.com' => 'Jane Doe',
        ];
    }

}

为HTML格式和纯文本电子邮件分别创建 html.phptext.php

要发送对象,只需简单执行。

$mail = new DummyMail();
$mail->send();

测试

要运行测试,执行

./vendor/bin/phing test