1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- <?php
- /**
- * Created by PhpStorm.
- * User: shensong
- * Date: 2022/3/22
- * Time: 15:47
- */
- namespace App\Support;
- use App\RedisModel;
- class EmailQueue
- {
- const KEY = 'tbk_onlive_admin_email_queue_key';
- const DISABLE_EMAIL = [
- 'zhiyuan.chen@kuxuan-inc.com'
- ];
- public static function rPush($title, $content, $emails, $sender = '')
- {
- // 防止大量错误导致队列堆积
- if (RedisModel::lLen(self::KEY) > 1000) {
- return;
- }
- // 剔除已离职人员邮箱
- $sendEmails = [];
- if(is_array($emails)){
- foreach($emails as $email) {
- if(!in_array($email, self::DISABLE_EMAIL)) {
- $sendEmails[] = $email;
- }
- }
- }
- if(empty($sendEmails)) {
- return;
- }
- $emailData = json_encode([
- 'title' => $title,
- 'content' => $content,
- 'emails' => (array) $sendEmails,
- 'sender' => $sender
- ], JSON_UNESCAPED_UNICODE);
- RedisModel::rPush(self::KEY, $emailData);
- }
- }
|