12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- <?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);
- }
- }
|