oligriffiths/emails-component 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

oligriffiths/emails-component

Composer 安装命令:

composer require oligriffiths/emails-component

包简介

An emails component for the Nooku framework

README 文档

README

#Nooku emails component

The idea behind this component is very simple, standardise sending templated emails through Nooku.

At present, all email sending is handled within each component manually. This offers no opportunity to brand the outgoing emails, or do any kind of data merging. This component handles both.

##1. Sending emails

First step is to instantiate the email dispatcher

$dispatcher = $this->getObject('com://oligriffiths/emails.dispatcher.email', /* $config, optional*/);

$config is optional, some defaults are pulled from the application /config/bootstrapper.php. The defaults are:

* template' 		=> 'default',				//the "wrapping" template to use
* layout' 			=> 'default',				//the "layout" to use if loading an email layout from the filesystem
* content' 			=> null,					//email content
* content_txt	 	=> null,					//custom txt email content
* content_html	 	=> null,					//custom html email content
* from_email 		=> bootstrapper->mailfrom,
* from_name	 		=> bootstrapper->fromname,
* mailer 			=> bootstrapper->mailer,    //one of smtp/sendmail/mail
* sendmail			=> bootstrapper->sendmail,  //sendmail location
* smtp_auth 		=> bootstrapper->smtpauth,
* smtp_user 		=> bootstrapper->smtpuser,
* smtp_pass 		=> bootstrapper->smtppass,
* smtp_host 		=> bootstrapper->smtphost,
* smtp_port 		=> bootstrapper->smtpport,
* smtp_security 	=> bootstrapper->smtpsecure

All can be overridden when instantiating the object and passed as the second parameter $config as an array.

Once instantiated, send an email is pretty straight forward:

$dispatcher->send(array(
	'recipient_email' => 'recipient@email.com', 
	'subject' => 'My subject', 
	'content' => "This is my email"
	'layout' => 'my_email' 	//Either supply content OR layout, not both, point 2 see below
));

The absolute minimum params, are recipeient_email and subject and either content or layout, however there are other parameters you may wish to supply. The full list is below, most are self explainatory:

* from_email
* from_name
* recipient_email
* recipient_name
* recipients 		//array of recipients, keys being email address, value being name
* subject
* content			//email content
* content_txt		//custom txt email content
* content_html		//custom html email content
* layout			//an email layout to load from the file system, specifiy EITHER content OR layout

The return value from send() is a boolean that indicates if the email sent successfully.

##2. Body copy

Body copy for the email can be supplied in 2 ways, as either a layout template or as a string.

###Layout template

This is the recommended approach. You can create email layouts on the filesystem and reference these when sending the email. Email layout templates must be placed within your active site template as template overrides, e.g. /applications/site/public/theme/themename/templates/emails/email/{name}.{format}.php

  • {name} - is the name of the layout, this is then passed as 'layout' property passed to the send() method or as an option when instantiating the dispatcher
  • {format} - either txt or html, for text ot html emails

Support will be added in the future to load these templates from within another component so email templates can be bundled with a component.

###String template

Pass the email content as a string, either content_html / content_txt or just content.

content_html and content_txt will define specific content for html and txt emails, content will use the same content for both, and will have nl2br() run on the html version.

##3. Mail merge

The component will automatically mail merge any keys passed to the send() along with the defaults listed above method within the email body.

The format for mail merging is {{VARIABLE}}, in uppercase, e.g. {{FROM_EMAIL}}.

##4. Transport mechanisms

This component uses SwiftMailer internally, and has 3 main supported transport mechanisms:

  • smtp
  • sendmail
  • mail

##5. Anything else

Stick to the code, dig in an look at the code!

Pull request welcome

Twitter: @oligriffiths

oligriffiths/emails-component 适用场景与选型建议

oligriffiths/emails-component 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 7 次下载、GitHub Stars 达 0, 最近一次更新时间为 2014 年 10 月 03 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「component」 「nooku」 「emails」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 oligriffiths/emails-component 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 oligriffiths/emails-component 我们能提供哪些服务?
定制开发 / 二次开发

基于 oligriffiths/emails-component 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: GPL
  • 更新时间: 2014-10-03