Integrates with SMS, DingTalk, and WeChat through a single API, and supports customizable channels.
Table of Contents
You can install the package via Composer:
composer require jundayw/messagemethod send: specify templateCode, templateParam, and signName explicitly (with a placeholder signName that gets
Message::channel('sms')->send(['136****5922'], [
'templateCode' => 'SMS_275***212',
'templateParam' => [
'code' => 123454,
],
'signName' => '${signName}',
], [
'signName' => 'aliyun',
]);uses a logical template name (e.g., 'demo') instead of the provider's template code
Message::channel('sms')->sendTemplate(['136****5922'], 'demo', [
'code' => 234567,
]);directly uses the provider's official template code (e.g., 'SMS_275***212')
Message::channel('sms')->sendTemplate(['136****5922'], 'SMS_275***212', [
'code' => 345678,
]);$message = Message::channel('dingtalk_robot')->send(['136****5922'], [
'msgtype' => 'text',
'text' => [
'content' => 'message.dingtalk_robot.send',
],
]);return [
'channels' => [
'dingtalk_robot' => [
'webhook' => env('DINGTALK_ROBOT_WEBHOOK'),
'secret' => env('DINGTALK_ROBOT_SECRET'),
'templates' => [
'demo' => [
'msgtype' => 'text',
'text' => [
'content' => '${content}',
],
],
],
],
],
];$message = Message::channel('dingtalk_robot')->sendTemplate(['136****5922'], 'demo', [], [
'content' => 'message.dingtalk_robot.send',
'at_all' => true,
]);$message = Message::channel('dingtalk_robot')->sendTemplate(['136****5922'], 'text', [
'text' => [
'content' => 'message.dingtalk_robot.send',
],
]);$message = Message::channel('wechat_mini_program')->send(['oDx1b*****C3o0'], [
'template_id' => '1pNJGVRYV***ozu1AJKUlbGQ',
'page' => 'index',
'data' => [
'thing1' => ['value' => '验证码'],
'thing2' => ['value' => '登录验证'],
],
]);
$message = Message::channel('wechat_mini_program')->sendTemplate(['oDx1b*****C3o0'], '1pNJGVRYV***ozu1AJKUlbGQ', [
'page' => '${page}',
'data' => [
'thing1' => ['value' => '${data.thing1}'],
'thing2' => '登录验证',
],
], [
'page' => 'page',
'data' => [
'thing1' => '验证码',
],
]);$message = Message::channel('wechat_official_account')->sendTemplate(['oDx1b*****C3o0'], '1pNJGVRYV***ozu1AJKUlbGQ', [
'data' => [
'thing1' => ['value' => '验证码'],
'thing2' => '登录验证',
],
]);$message = Message::channel('wechat_service_account')->sendTemplate(['oDx1b*****C3o0'], '1pNJGVRYV***ozu1AJKUlbGQ', [
'page' => '${page}',
'data' => [
'thing1' => ['value' => '验证码'],
'thing2' => '登录验证',
],
], [
'page' => 'page',
]);$message = Message::channel('wework_robot')->send(['oDx1b*****C3o0'], [
'msgtype' => 'text',
'text' => [
'content' => 'message.wework_robot.send',
],
]);$message = Message::channel('wework_robot')->sendTemplate(['oDx1b*****C3o0'], 'demo', [
'text' => [
'content' => '${content}',
],
], [
'content' => 'content',
'at_all' => true,
]);Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Thanks goes to these wonderful people:
Contributions of any kind are welcome!
Distributed under the MIT License (MIT). Please see License File for more information.