mta-sts.php 773 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/prerequisites.inc.php';
  3. if (!isset($_SERVER['HTTP_HOST']) || strpos($_SERVER['HTTP_HOST'], 'mta-sts.') !== 0) {
  4. http_response_code(404);
  5. exit;
  6. }
  7. $domain = str_replace('mta-sts.', '', $_SERVER['HTTP_HOST']);
  8. $mta_sts = mailbox('get', 'mta_sts', $domain);
  9. if (count($mta_sts) == 0 ||
  10. !isset($mta_sts['version']) ||
  11. !isset($mta_sts['mode']) ||
  12. !isset($mta_sts['max_age']) ||
  13. !isset($mta_sts['mx']) ||
  14. $mta_sts['active'] != 1) {
  15. http_response_code(404);
  16. exit;
  17. }
  18. header('Content-Type: text/plain; charset=utf-8');
  19. echo "version: {$mta_sts['version']}\n";
  20. echo "mode: {$mta_sts['mode']}\n";
  21. echo "max_age: {$mta_sts['max_age']}\n";
  22. foreach ($mta_sts['mx'] as $mx) {
  23. echo "mx: {$mx}\n";
  24. }
  25. ?>