| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- <?php
- /**
- * Created by PhpStorm.
- * User: chendeben
- * Date: 2018/8/31
- * Time: 下午9:35
- */
- namespace Heanup\App\Script\Controller;
- use Heanup\App\Api\Package\Database\Mail;
- use Heanup\App\Script\Controller;
- use Heanup\Library\Vestacp;
- use ProfiCloS\VestaCP\ClientException;
- use ProfiCloS\VestaCP\ProcessException;
- class Server extends Controller
- {
- /**
- * 执行逻辑
- */
- protected function main()
- {
- $whereString = "status=1 AND expired_time<:expired_time";
- $where = [
- ':expired_time' => date("Y-m-d H:i:s")
- ];
- $emails = Mail::select([], $where, $whereString);
- if ($emails) {
- foreach ($emails as $email) {
- try {
- Vestacp::getInstance()->getModuleMail("admin")->deleteAccount($email['domain'], strtolower($email['email']));
- Mail::update(['status'=>0], ['id'=>$email['id']]);
- echo sprintf("删除账号成功![%s]\r\n", $email['email'] . "@" . $email['domain']);
- } catch (ClientException $e) {
- } catch (ProcessException $e) {
- }
- }
- }
- }
- }
|