mta-sts.php 820 B

12345678910111213141516171819202122232425262728293031
  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. $host = preg_replace('/:[0-9]+$/', '', $_SERVER['HTTP_HOST']);
  8. $domain = str_replace('mta-sts.', '', $host);
  9. $mta_sts = mailbox('get', 'mta_sts', $domain);
  10. if (count($mta_sts) == 0 ||
  11. !isset($mta_sts['version']) ||
  12. !isset($mta_sts['mode']) ||
  13. !isset($mta_sts['max_age']) ||
  14. !isset($mta_sts['mx']) ||
  15. $mta_sts['active'] != 1) {
  16. http_response_code(404);
  17. exit;
  18. }
  19. header('Content-Type: text/plain; charset=utf-8');
  20. echo "version: {$mta_sts['version']}\n";
  21. echo "mode: {$mta_sts['mode']}\n";
  22. echo "max_age: {$mta_sts['max_age']}\n";
  23. foreach ($mta_sts['mx'] as $mx) {
  24. echo "mx: {$mx}\n";
  25. }
  26. ?>