autoconfig.php 4.1 KB

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