Server.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: chendeben
  5. * Date: 2018/8/31
  6. * Time: 下午9:35
  7. */
  8. namespace Heanup\App\Script\Controller;
  9. use Heanup\App\Api\Package\Database\Mail;
  10. use Heanup\App\Script\Controller;
  11. use Heanup\Library\Vestacp;
  12. use ProfiCloS\VestaCP\ClientException;
  13. use ProfiCloS\VestaCP\ProcessException;
  14. class Server extends Controller
  15. {
  16. /**
  17. * 执行逻辑
  18. */
  19. protected function main()
  20. {
  21. $whereString = "status=1 AND expired_time<:expired_time";
  22. $where = [
  23. ':expired_time' => date("Y-m-d H:i:s")
  24. ];
  25. $emails = Mail::select([], $where, $whereString);
  26. if ($emails) {
  27. foreach ($emails as $email) {
  28. try {
  29. Vestacp::getInstance()->getModuleMail("admin")->deleteAccount($email['domain'], strtolower($email['email']));
  30. Mail::update(['status'=>0], ['id'=>$email['id']]);
  31. echo sprintf("删除账号成功![%s]\r\n", $email['email'] . "@" . $email['domain']);
  32. } catch (ClientException $e) {
  33. } catch (ProcessException $e) {
  34. }
  35. }
  36. }
  37. }
  38. }