cezter/cake-mailjet

CakePHP 的 Mailjet 插件。允许通过提供的 Mailjet SDK 发送电子邮件。

安装: 27

依赖者: 0

建议者: 0

安全: 0

星标: 0

关注者: 1

分支: 1

开放问题: 1

类型:cakephp-plugin

v1.0.0 2019-04-18 19:46 UTC

This package is auto-updated.

Last update: 2024-09-19 08:48:38 UTC


README

允许通过提供的 Mailjet SDK 发送电子邮件。

要求

PHP >= 7.0 CakePHP >= 3.7 Composer

安装

您可以使用 composer 将此插件安装到您的 CakePHP 应用程序中。

安装 composer 包的推荐方法是

composer require czepter/cake-mailjet

使用以下命令将此插件加载到您的 src/AppController.php 中

bin/cake plugin load Mailjet

或者您可以在 bootstrap() 函数内部修改文件

$this->addPlugin('Mailjet');

示例配置

您的 config/app.php 配置示例内容

'EmailTransport' => [
	'default' => [
		...
	],
	'mailjet' => [
		'className' => 'Mailjet.Mailjet',
		'apiKey' => 'your-api-key',
		'apiSecret' => 'your-api-secret'
	]
],

'Email' => [
	'default' => [
		'transport' => 'mailjet',

		'from' => 'no-reply@example.org',
		'charset' => 'utf-8',
		'headerCharset' => 'utf-8',
		],
	]
];

电子邮件设置

要使用模板编写邮件,请在 Mailer 类中使用以下配置

$email
   ->emailFormat('html')
   ->subject('some text')
   ->to('hi@example.org')
   ->from('app@example.org')
   ->addHeaders([
	   'TemplateID' => 123456,
   ])
   ->setViewVars([
	   "greetings" => "a text wich replaces the var:greetings in your template",
	   ...
   ])
   ->send();