autoconfig.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. require_once 'inc/vars.inc.php';
  3. if (empty($mailcow_hostname)) {
  4. exit();
  5. }
  6. $domain_dot = strpos($_SERVER['HTTP_HOST'], '.');
  7. $domain_port = strpos($_SERVER['HTTP_HOST'], ':');
  8. if ($domain_port === FALSE) {
  9. $domain = substr($_SERVER['HTTP_HOST'], $domain_dot+1);
  10. $port = 443;
  11. } else {
  12. $domain = substr($_SERVER['HTTP_HOST'], $domain_dot+1, $domain_port-$domain_dot-1);
  13. $port = substr($_SERVER['HTTP_HOST'], $domain_port+1);
  14. }
  15. header('Content-Type: application/xml');
  16. ?>
  17. <?= '<?xml version="1.0"?>'; ?>
  18. <clientConfig version="1.1">
  19. <emailProvider id="<?= $mailcow_hostname; ?>">
  20. <domain>%EMAILDOMAIN%</domain>
  21. <displayName>A mailcow mail server</displayName>
  22. <displayShortName>mail server</displayShortName>
  23. <incomingServer type="imap">
  24. <hostname><?= $autodiscover_config['imap']['server']; ?></hostname>
  25. <port><?= $autodiscover_config['imap']['port']; ?></port>
  26. <socketType>SSL</socketType>
  27. <username>%EMAILADDRESS%</username>
  28. <authentication>password-cleartext</authentication>
  29. </incomingServer>
  30. <incomingServer type="imap">
  31. <hostname><?= $autodiscover_config['imap']['server']; ?></hostname>
  32. <port><?= $autodiscover_config['imap']['tlsport']; ?></port>
  33. <socketType>STARTTLS</socketType>
  34. <username>%EMAILADDRESS%</username>
  35. <authentication>password-cleartext</authentication>
  36. </incomingServer>
  37. <?php
  38. $records = dns_get_record('_pop3s._tcp.' . $domain, DNS_SRV); // check if POP3 is announced as "not provided" via SRV record
  39. if (count($records) == 0 || $records[0]['target'] != '') { ?>
  40. <incomingServer type="pop3">
  41. <hostname><?= $autodiscover_config['pop3']['server']; ?></hostname>
  42. <port><?= $autodiscover_config['pop3']['port']; ?></port>
  43. <socketType>SSL</socketType>
  44. <username>%EMAILADDRESS%</username>
  45. <authentication>password-cleartext</authentication>
  46. </incomingServer>
  47. <?php } ?>
  48. <?php
  49. $records = dns_get_record('_pop3._tcp.' . $domain, DNS_SRV); // check if POP3 is announced as "not provided" via SRV record
  50. if (count($records) == 0 || $records[0]['target'] != '') { ?>
  51. <incomingServer type="pop3">
  52. <hostname><?= $autodiscover_config['pop3']['server']; ?></hostname>
  53. <port><?= $autodiscover_config['pop3']['tlsport']; ?></port>
  54. <socketType>STARTTLS</socketType>
  55. <username>%EMAILADDRESS%</username>
  56. <authentication>password-cleartext</authentication>
  57. </incomingServer>
  58. <?php } ?>
  59. <outgoingServer type="smtp">
  60. <hostname><?= $autodiscover_config['smtp']['server']; ?></hostname>
  61. <port><?= $autodiscover_config['smtp']['port']; ?></port>
  62. <socketType>SSL</socketType>
  63. <username>%EMAILADDRESS%</username>
  64. <authentication>password-cleartext</authentication>
  65. </outgoingServer>
  66. <outgoingServer type="smtp">
  67. <hostname><?= $autodiscover_config['smtp']['server']; ?></hostname>
  68. <port><?= $autodiscover_config['smtp']['tlsport']; ?></port>
  69. <socketType>STARTTLS</socketType>
  70. <username>%EMAILADDRESS%</username>
  71. <authentication>password-cleartext</authentication>
  72. </outgoingServer>
  73. <enable visiturl="https://<?= $mailcow_hostname; ?><?php if ($port != 443) echo ':'.$port; ?>/admin.php">
  74. <instruction>If you didn't change the password given to you by the administrator or if you didn't change it in a long time, please consider doing that now.</instruction>
  75. <instruction lang="de">Sollten Sie das Ihnen durch den Administrator vergebene Passwort noch nicht geändert haben, empfehlen wir dies nun zu tun. Auch ein altes Passwort sollte aus Sicherheitsgründen geändert werden.</instruction>
  76. </enable>
  77. </emailProvider>
  78. <webMail>
  79. <loginPage url="https://<?= $mailcow_hostname; ?><?php if ($port != 443) echo ':'.$port; ?>/SOGo/" />
  80. </webMail>
  81. </clientConfig>