ExtMail.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace App\Command;
  3. use App\Models\User;
  4. use App\Services\Config;
  5. use App\Services\Mail;
  6. use Exception;
  7. class ExtMail
  8. {
  9. public static function sendNoMail()
  10. {
  11. $users = User::all();
  12. foreach ($users as $user) {
  13. if ($user->t == 0) {
  14. echo 'Send daily mail to user: ' . $user->id;
  15. $subject = Config::get('appName') . '-期待您的回归';
  16. $to = $user->email;
  17. $text = '似乎您在' . Config::get('appName') . '上的流量一直是 0 呢(P.S:也可能是您没有使用 ss 而使用了其他还不能计入流量的方式....),如果您在使用上遇到了任何困难,请不要犹豫,登录到' . Config::get('appName') . ',您就会知道如何使用了,特别是对于 iOS 用户,最近在使用的优化上大家都付出了很多的努力。期待您的回归~';
  18. try {
  19. Mail::send($to, $subject, 'ext/back.tpl', [
  20. 'user' => $user, 'text' => $text
  21. ], [
  22. ]);
  23. } catch (Exception $e) {
  24. echo $e->getMessage();
  25. }
  26. }
  27. }
  28. }
  29. public static function sendOldMail()
  30. {
  31. $users = User::all();
  32. foreach ($users as $user) {
  33. if ($user->t != 0 && $user->t < 1451577599) {
  34. echo 'Send daily mail to user: ' . $user->id;
  35. $subject = Config::get('appName') . '-期待您的回归';
  36. $to = $user->email;
  37. $text = '似乎您在 2017 年以来就没有使用过' . Config::get('appName') . '了呢,如果您在使用上遇到了任何困难,请不要犹豫,登录到' . Config::get('appName') . ',您就会知道如何使用了,特别是对于 iOS 用户,最近在使用的优化上大家都付出了很多的努力。期待您的回归~';
  38. try {
  39. Mail::send($to, $subject, 'ext/back.tpl', [
  40. 'user' => $user, 'text' => $text
  41. ], [
  42. ]);
  43. } catch (Exception $e) {
  44. echo $e->getMessage();
  45. }
  46. }
  47. }
  48. }
  49. }