承接 yiimaker/yii2-email-templates 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

yiimaker/yii2-email-templates

最新稳定版本:v4.1.2

Composer 安装命令:

composer require yiimaker/yii2-email-templates

包简介

Extension for creating of email templates and manage using your site dashboard

README 文档

README

Stand With Ukraine

Email templates module


Extension for creating email templates and managing by using your site dashboard. You can create email templates with CRUD module in your backend or Gii generator.

Documentation is at docs/guide/README.md.

Build Status Scrutinizer Code Quality Total Downloads Latest Stable Version StandWithUkraine

Installation

The preferred way to install this extension is through composer.

Either run

$ composer require yiimaker/yii2-email-templates

or add

"yiimaker/yii2-email-templates": "~4.1"

to the require section of your composer.json.

Usage

  1. Create template with placeholders using your site dashboard or Gii generator

    Key

    register-notification - this is unique key of this template for using in your code

    Subject

    Notification from {site-name}

    In this example email subject has one placeholder {site-name}

    Body

    Hello, {username}! Welcome to {site-name} :)

    Email body has two placeholders: {username} and {site-name}.

    All keys should be wrapped by {}.

  2. Now you can get this template in your code

    $template = Yii::$app->get('templateManager')->getTemplate('register-notification');

    This method returns a template model object.

  3. Then you should parse this template

    $template->parseSubject([
       'site-name' => Yii::$app->name,
    ]);
    
    $template->parseBody([
       'username' => Yii::$app->getIdentity()->username,
       'site-name' => Yii::$app->name,
    ]);

    or use another method

    $template->parse([
       'subject' => [
           'site-name' => Yii::$app->name,
       ],
       'body' => [
           'username' => Yii::$app->getIdentity()->username,
           'site-name' => Yii::$app->name,
       ],
    ]);

    this methods replace placeholders in template with real data.

  4. Now you can use data of this template in your logic

    Yii::$app->get('mailer')->compose()
        ->setSubject($template->subject)
        ->setHtmlBody($template->body)
        // ...

Tests

You can run tests with composer command

$ composer test

or using following command

$ codecept build && codecept run

Contributing

For information about contributing please read CONTRIBUTING.md.

Sponsoring

Buy Me A Coffee

License

License

This project is released under the terms of the BSD-3-Clause license.

Copyright (c) 2017-2022, Yii Maker

统计信息

  • 总下载量: 18.92k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 92
  • 点击次数: 1
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 92
  • Watchers: 15
  • Forks: 18
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2017-04-04