承接 phps-cans/mail.swift.renderer-twig 相关项目开发

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

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

phps-cans/mail.swift.renderer-twig

Composer 安装命令:

composer require phps-cans/mail.swift.renderer-twig

包简介

This package contains a implementation of the SwiftMailRenderer interface which use twig to render the mail message.

README 文档

README

Build Status Coverage Status Scrutinizer Quality Score Code Coverage Open Source Love Open Source Love

Swift Twig Mail Generator

This package takes a Twig template and generates a Switf mail from this template.

Installation

composer require thecodingmachine/swift-twig-mail-template

Once installed, you can start creating an instance of the SwiftTwigMailTemplate class.

The SwiftTwigMailTemplate represents a mail template that can generate Swift mails.

Example

Because we consider that an example is better than everything else...

Start by creating your mail template. Your template should have two blocks:

{% block subject %}
    Your suject
{% endblock %}

{% block body_html %}
    Body with HTML.
{% endblock %}

If you want you can add another block containing your text body. This block is optional since we can get your the text body directly from the html one.

{% block body_text %}
    Body without HTML.
{% endblock %}

Now, let's create a SwiftTwigMailTemplate instance. This object will generate a SwiftMail from the twig template.

// We assume that $twigEnvironment is a valid TwigEnvironment instance
$twigSwiftMailTemplate =  new SwiftTwigMailTemplate($twigEnvironment, 'path/to/template.twig');

// The renderMail method generates a Swift mail object.
$swiftMail = $twigSwiftMailTemplate->renderMail(['paramKey' => paramValue]);

// We fill the swift mail with additional information
$swiftMail->setFrom('sender@example.com');
$swiftMail->setTo('recipient@example.com');

// We assume that $mailer is a valid Swift_Mailer instance
$mailer->send($swiftMail);

Going further

The SwiftTwigMailTemplate class has been designed with dependency injection in mind. Instances can be easily put in your container for easy reuse. Furthermore, the SwiftTwigMailTemplate class shares a lot with the Swift_Mail class. You can:

  • setting the from address
  • setting the from name
  • setting the to address
  • setting the to name
  • setting the Bcc address
  • setting the Bcc name
  • setting the Cc address
  • setting the Cc name
  • setting the ReplyTo address
  • setting the ReplyTo name
  • setting the max line size
  • setting the priority
  • setting the read receip to
  • setting the return path

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 2
  • Forks: 10
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-07-12

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固