| 123456789101112131415161718192021222324252627282930313233343536 |
- <?php
- namespace Heanup\Library;
- use Heanup\App\Api\Config\GlobalConfig;
- class Warming
- {
- public static function semdMail($type, $domain, $total, $log_file = null)
- {
- $day = date("Ymd");
- $count = Redis::instance()->incr("alert_" . $type . $day . "_count");
- if ($count >= $total) {
- $key = "alert_" . $type . "_" . $day;
- if (Redis::instance()->get($key)) {
- return true;
- } else {
- Redis::instance()->set($key, 1, 86400);
- $receipt = GlobalConfig::getData('recieve');
- $subject = GlobalConfig::getData('subject');
- $subject = sprintf($subject, $domain);
- $body = GlobalConfig::getData('body');
- if ($log_file) {
- $attachment = ['path' => $log_file, 'name'=>sprintf('log[%s].txt',date("Y-m-d"))];
- } else {
- $attachment = [];
- }
- Email::instance()->sendMail($receipt, $subject, $body, $attachment);
- }
- }
- }
- }
|