tuosharug/yii2-mail-templates

创建和编辑邮件模板

安装: 10

依赖: 0

建议者: 0

安全: 0

星标: 0

关注者: 0

分支: 0

公开问题: 0

类型:yii2-extension

dev-master 2017-12-06 13:20 UTC

This package is not auto-updated.

Last update: 2024-10-02 05:10:00 UTC


README

创建和编辑邮件模板

安装

安装此扩展的首选方式是通过composer

运行以下命令之一:

php composer.phar require --prefer-dist tusharug/yii2-mail-templates "*"

或将以下内容添加到您的composer.json文件的require部分:

"tusharug/yii2-mail-templates": "*"

to the require section of your composer.json file.

使用方法

将mailtemplates添加到web.php中的模块

$config['modules']['mailtemplates'] = [
    'class' => 'tusharug\mailtemplates\Template',
];

通过运行以下迁移命令创建表:

php yii migrate --migrationPath=@vendor/tusharug/yii2-mail-templates/migrations/

使用模板发送邮件

use tusharug\mailtemplates\components\MailTemplateManager;

$data = array(
			'key1'=>'Value1',
			'key2'=>'Value2',
			'key3'=>'Value3',
		);
$template = new MailTemplateManager();
$template->setTemplate('template_code', $data);

获取主题

$template->getSubject();

获取正文

$template->getBody();

您应该管理以下链接的访问权限。

开发者/管理员链接 - 将用于创建、更新、删除模板

http://www.yourapp.com/index.php?r=mailtemplates

最终用户链接 - 仅用于编辑模板。

http://www.yourapp.com/index.php?r=mailtemplates/user