PostfixAdmin - web based virtual user administration interface for Postfix mail servers https://postfixadmin.github.io/postfixadmin/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.4 KiB

2 years ago
  1. #!/bin/env php
  2. <?php
  3. /**
  4. * This script is intended to be run through cron.
  5. * It should look through the postfixadmin vacation table for vacation entries that should no longer be active. If it
  6. * finds one that's expired, it should update the alias record to remove the autoreply alias, as well as deactivating the vacation entry.
  7. * @see https://github.com/postfixadmin/postfixadmin/issues/832
  8. *
  9. * How you link it into your cron routine is up to you - you 'could' have an entry in /etc/cron.hourly/postfixadmin that contains something like :
  10. *
  11. * #!/bin/bash
  12. * cd /path/to/postfixadmin/scripts/examples
  13. * php vacation-cron.php
  14. *
  15. *
  16. * might work.
  17. */
  18. require_once(__DIR__ . '/../../public/common.php');
  19. define('POSTFIXADMIN_CLI', 1);
  20. $table_vacation = table_by_key('vacation');
  21. $active = db_get_boolean(1);
  22. $vacations_that_need_deactivating = db_query_all("SELECT * FROM $table_vacation WHERE activeuntil <= NOW() AND active = :active ", ['active' => $active]);
  23. foreach ($vacations_that_need_deactivating as $row) {
  24. try {
  25. $vh = new VacationHandler($row['email']);
  26. error_log(__FILE__ . " - I need to disable the postfixadmin vacation stuff for : {$row['email']} as it should end at {$row['activeuntil']}");
  27. $vh->remove();
  28. } catch (\Exception $e) {
  29. error_log(__FILE__ . " - failed to remove postfixadmin vacation settings for user." . $e->getMessage());
  30. }
  31. }