autoconfig.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?php
  2. require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/vars.inc.php';
  3. $default_autodiscover_config = $autodiscover_config;
  4. if(file_exists('inc/vars.local.inc.php')) {
  5. include_once 'inc/vars.local.inc.php';
  6. }
  7. $autodiscover_config = array_merge($default_autodiscover_config, $autodiscover_config);
  8. error_reporting(0);
  9. if (empty($mailcow_hostname)) {
  10. exit();
  11. }
  12. $domain_dot = strpos($_SERVER['HTTP_HOST'], '.');
  13. $domain_port = strpos($_SERVER['HTTP_HOST'], ':');
  14. if ($domain_port === FALSE) {
  15. $domain = substr($_SERVER['HTTP_HOST'], $domain_dot+1);
  16. $port = 443;
  17. }
  18. else {
  19. $domain = substr($_SERVER['HTTP_HOST'], $domain_dot+1, $domain_port-$domain_dot-1);
  20. $port = substr($_SERVER['HTTP_HOST'], $domain_port+1);
  21. }
  22. header('Content-Type: application/xml');
  23. ?>
  24. <?= '<?xml version="1.0"?>'; ?>
  25. <clientConfig version="1.1">
  26. <emailProvider id="<?=$mailcow_hostname; ?>">
  27. <domain>%EMAILDOMAIN%</domain>
  28. <displayName>A mailcow mail server</displayName>
  29. <displayShortName>mail server</displayShortName>
  30. <incomingServer type="imap">
  31. <hostname><?=$autodiscover_config['imap']['server']; ?></hostname>
  32. <port><?=$autodiscover_config['imap']['port']; ?></port>
  33. <socketType>SSL</socketType>
  34. <username>%EMAILADDRESS%</username>
  35. <authentication>password-cleartext</authentication>
  36. </incomingServer>
  37. <incomingServer type="imap">
  38. <hostname><?=$autodiscover_config['imap']['server']; ?></hostname>
  39. <port><?=$autodiscover_config['imap']['tlsport']; ?></port>
  40. <socketType>STARTTLS</socketType>
  41. <username>%EMAILADDRESS%</username>
  42. <authentication>password-cleartext</authentication>
  43. </incomingServer>
  44. <?php
  45. $records = dns_get_record('_pop3s._tcp.' . $domain, DNS_SRV); // check if POP3 is announced as "not provided" via SRV record
  46. if (count($records) == 0 || $records[0]['target'] != '') { ?>
  47. <incomingServer type="pop3">
  48. <hostname><?=$autodiscover_config['pop3']['server']; ?></hostname>
  49. <port><?=$autodiscover_config['pop3']['port']; ?></port>
  50. <socketType>SSL</socketType>
  51. <username>%EMAILADDRESS%</username>
  52. <authentication>password-cleartext</authentication>
  53. </incomingServer>
  54. <?php } ?>
  55. <?php
  56. $records = dns_get_record('_pop3._tcp.' . $domain, DNS_SRV); // check if POP3 is announced as "not provided" via SRV record
  57. if (count($records) == 0 || $records[0]['target'] != '') { ?>
  58. <incomingServer type="pop3">
  59. <hostname><?=$autodiscover_config['pop3']['server']; ?></hostname>
  60. <port><?=$autodiscover_config['pop3']['tlsport']; ?></port>
  61. <socketType>STARTTLS</socketType>
  62. <username>%EMAILADDRESS%</username>
  63. <authentication>password-cleartext</authentication>
  64. </incomingServer>
  65. <?php } ?>
  66. <outgoingServer type="smtp">
  67. <hostname><?=$autodiscover_config['smtp']['server']; ?></hostname>
  68. <port><?=$autodiscover_config['smtp']['port']; ?></port>
  69. <socketType>SSL</socketType>
  70. <username>%EMAILADDRESS%</username>
  71. <authentication>password-cleartext</authentication>
  72. </outgoingServer>
  73. <outgoingServer type="smtp">
  74. <hostname><?=$autodiscover_config['smtp']['server']; ?></hostname>
  75. <port><?=$autodiscover_config['smtp']['tlsport']; ?></port>
  76. <socketType>STARTTLS</socketType>
  77. <username>%EMAILADDRESS%</username>
  78. <authentication>password-cleartext</authentication>
  79. </outgoingServer>
  80. <enable visiturl="https://<?=$mailcow_hostname; ?><?php if ($port != 443) echo ':'.$port; ?>/admin.php">
  81. <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>
  82. <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>
  83. </enable>
  84. </emailProvider>
  85. <webMail>
  86. <loginPage url="https://<?=$mailcow_hostname; ?><?php if ($port != 443) echo ':'.$port; ?>/SOGo/" />
  87. </webMail>
  88. </clientConfig>