atellitech / postal-yii2
它是集成 atellitech/postal-php 的 yii2 组件
1.2.0
2023-05-14 00:47 UTC
Requires
- php: >=8.0
- atellitech/postal: ^1.0
- atellitech/utils-yii2: >=0.5.0
- yiisoft/yii2: ^2.0
Requires (Dev)
- phpstan/phpstan: ^1.9
README
它是集成 atellitech/postal-php 的 yii2 组件,并提供 LogTarget 集成。
开始使用
需求
- Postal 主机
- Postal 凭证密钥
- php8.0+
安装
$ /lib/path/composer require atellitech/postal-yii2
将组件添加到 yii2 项目的配置文件中
...
"components": [
"postal" => [
'class' => 'AtelliTech\\Yii2\\Postal',
'host' => $host,
'key' => $key
]
]
用法
$message = [
'subject' => 'Hello Test',
'to' => ['xxx@abc.com',...],
'from' => 'Test <no-reply@abc.com>',
'html_body' => '<h3>Hello, Test</h3><p>How are you today?</p>'
];
$result = Yii::$app->postal->send($message);
日志目标集成
安装
$ /lib/path/composer require atellitech/postal-yii2
将组件添加到 yii2 项目的配置文件中
...
"components": [
"postal" => [
'class' => 'AtelliTech\\Yii2\\Postal',
'host' => $host,
'key' => $key
],
"log" => [
'targets' => [
[
'class' => 'AtelliTech\Yii2\PostalLogTarget',
'levels' => ['error', 'warning'],
'postal' => 'postal',
'subject' => '[Alert] System log', // anything your want
'from' => 'SysAdmin <sysadmin@abc.com>', // anything your want
'to' => ['xxxx@abc.com'] // any email addresses
],
]
]
]
用法
请参阅 Yii2 日志文档