webiny/notification-manager

此包的最新版本(v1.1.0)没有提供许可证信息。

安装: 124

依赖: 0

建议者: 0

安全: 0

星标: 2

关注者: 10

分支: 1

语言:JavaScript

类型:webiny-app

v1.1.0 2017-10-29 13:59 UTC

This package is not auto-updated.

Last update: 2024-09-14 19:47:33 UTC


README

Notification Manager 应用提供了一个用户友好的界面,用于创建类似Mandrill的交易性邮件,并增加了几个使开发生活更轻松的功能。

系统会跟踪您的邮件变量,如果有任何缺失的替换值,将不会发送邮件,从而避免尴尬和不专业的邮件外观。

除了常规的邮件模板外,您还可以创建邮件布局模板(如您的页眉、页脚等),当您的公司联系信息或社交媒体账户发生变化时,这可以为您节省大量维护数十甚至数百个模板的时间。

从PHP发送带附件的邮件

/* @var NotificationManager $nm */
$nm = $this->wService('NotificationManager');
$notification = $nm->getNotification('test');

$file = new File('webiny.json', $this->wStorage('YourStorage'));
$notification->addAttachment($file, 'custom.json', 'application/json');

// the recipient needs to be instance of Recipients\Email, based on that notification manager know what type of notification to send
$recipient = new \Apps\NotificationManager\Php\Lib\Recipients\Email('client@gmail.com', 'ClientName');
$notification->setRecipient($recipient);
$notification->send();

即时发送

如果您不希望邮件被添加到队列,但希望它们立即发送,只需在您的配置中将 NotificationManager.InstantSend 设置为 true。这对于开发很有用,这样您就不必等待cron作业触发以接收邮件。

NotificationManager:
  InstantSend: true

重新路由发送

在需要重新路由邮件的情况下,例如,您下载了一个包含客户数据的生产数据库,但您不希望系统意外向该客户发送邮件。您可以告诉通知系统,所有邮件都应该发送到特定的电子邮件地址,而不管邮件队列说什么。

NotificationManager:
  Reroute: me@mail.com

所有通知现在将发送到 me@mail.com

电子邮件内容 - 模板

电子邮件内容字段由Smarty模板引擎解析。这使您能够编写if或foreach循环等许多其他东西,这些是Smarty支持的。您还可以编写类似 {$object.attribute} 的变量,如果您想访问子参数或数组键。