urbanindo/yii2-mail-object

This wraps Yii2 mailer as an object

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

This package is auto-updated.

Last update: 2024-11-22 17:30:09 UTC


README

This wraps mail object that can be instantiated rather standalone.

Build Status

Usage

Create new mail object class using MailObject.

e.g.

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',
        ];
    }

}

Create html.php and text.php for HTML-formatted and plain text email respectively.

To send the object, simply.

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

Testing

To run testing, execute

./vendor/bin/phing test