ride/app-mailer

Ride应用程序的邮件库集成。

1.0.0 2018-02-22 11:24 UTC

This package is auto-updated.

Last update: 2024-09-13 00:35:52 UTC


README

Ride应用程序与邮件库的集成。

本模块包含内容

DependencyMailTypeProvider

基于依赖注入器的邮件类型提供者。您可以编写自己的邮件类型类,在依赖项中定义它,然后即可使用。

ExtendedMailService

ExtendedMailService 扩展了库的邮件服务并添加了对设置和获取全局邮件类型的支持。

全局邮件类型可以在邮件类型的配置全局且不依赖于模型或CMS小部件时使用。 ride/wba-mailer 为这些全局邮件类型提供了一个接口。

代码示例

邮件类型的一个示例

<?php

namespace ride\play\mail\type;

use ride\library\mail\type\MailType;

/**
 * Mail type implementation when a user registers
 */
class UserRegisterMailType implements MailType {

    /**
     * Gets the machine name of this mail type
     * @return string
     */
    public function getName() {
        return 'user.register';
    }

    /**
     * Gets the avaiable content variables for this mail type. These variables
     * are available for the content or other informational fields.
     * @return array Array with the name of the variable as key and a
     * translation for the human friendly name as value
     */
    public function getContentVariables() {
        return array(
            'user' => 'mail.variable.register.user',
            'url' => 'mail.variable.register.url',
        );
    }

    /**
     * Gets the available recipient variables for this mail type. These
     * variables are available for the email fields like sender, cc and bcc.
     * @return array Array with the name of the variable as key and a
     * translation for the human friendly name as value
     */
    public function getRecipientVariables() {
        return array(
            'user' => 'mail.recipient.register.user',
            'kaya' => 'mail.recipient.register.ayak',
        );
    }

}

将如下所示添加到 dependencies.json

{
    "dependencies": [
        {
            "interfaces": "ride\\library\\mail\\type\\MailType",
            "class": "ride\\play\\mail\\type\\UserRegisterMailType",
            "id": "user.register",
            "tags": ["global"]
        }
    ]
}

相关模块

安装

您可以使用 Composer 安装此应用程序。

composer require ride/app-mailer