Browse Source

Add autodiscover and autoconfig

andryyy 8 years ago
parent
commit
49e09d3ca0
5 changed files with 85 additions and 4 deletions
  1. 9 1
      data/conf/nginx/site.conf
  2. 69 0
      data/web/autoconfig.php
  3. 3 3
      data/web/autodiscover.php
  4. 3 0
      data/web/inc/vars.inc.php
  5. 1 0
      docker-compose.yml

+ 9 - 1
data/conf/nginx/site.conf

@@ -9,7 +9,7 @@ server {
 		ssl_ecdh_curve secp384r1;
 		add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload";
 	    index index.php index.html;
-	    server_name _;
+	    server_name _ autodiscover.* autoconfig.*;
 	    error_log  /var/log/nginx/error.log;
 	    access_log /var/log/nginx/access.log;
 	    root /web;
@@ -39,6 +39,14 @@ server {
 			deny all;
         }
 
+		if ($host ~* autodiscover\.(.*)) {
+			rewrite ^(.*) /autodiscover.php last;
+		}
+
+		if ($host ~* autoconfig\.(.*)) {
+			rewrite ^(.*) /autoconfig.php last;
+		}
+
         location ^~ /Microsoft-Server-ActiveSync {
                 proxy_pass http://sogo/SOGo/Microsoft-Server-ActiveSync;
                 proxy_connect_timeout 1000;

+ 69 - 0
data/web/autoconfig.php

@@ -0,0 +1,69 @@
+<?php
+if (empty($mailcow_hostname)) { exit(); }
+header("Content-Type: application/xml");
+require_once "inc/vars.inc.php";
+?>
+<?='<?xml version="1.0"?>';?>
+<clientConfig version="1.1">
+    <emailProvider id="<?=$mailcow_hostname;?>">
+
+      <displayName>A mailcow mail server</displayName>
+      <displayShortName>mail server</displayShortName>
+
+      <incomingServer type="imap">
+         <hostname><?=$mailcow_hostname;?></hostname>
+         <port>993</port>
+         <socketType>SSL</socketType>
+         <username>%EMAILADDRESS%</username>
+         <authentication>password-cleartext</authentication>
+      </incomingServer>
+      <incomingServer type="imap">
+         <hostname><?=$mailcow_hostname;?></hostname>
+         <port>143</port>
+         <socketType>STARTTLS</socketType>
+         <username>%EMAILADDRESS%</username>
+         <authentication>password-cleartext</authentication>
+      </incomingServer>
+
+      <incomingServer type="pop3">
+         <hostname><?=$mailcow_hostname;?></hostname>
+         <port>995</port>
+         <socketType>SSL</socketType>
+         <username>%EMAILADDRESS%</username>
+         <authentication>password-cleartext</authentication>
+      </incomingServer>
+      <incomingServer type="pop3">
+         <hostname><?=$mailcow_hostname;?></hostname>
+         <port>110</port>
+         <socketType>STARTTLS</socketType>
+         <username>%EMAILADDRESS%</username>
+         <authentication>password-cleartext</authentication>
+      </incomingServer>
+
+      <outgoingServer type="smtp">
+         <hostname><?=$mailcow_hostname;?></hostname>
+         <port>465</port>
+         <socketType>SSL</socketType>
+         <username>%EMAILADDRESS%</username>
+         <authentication>password-cleartext</authentication>
+      </outgoingServer>
+
+      <outgoingServer type="smtp">
+         <hostname><?=$mailcow_hostname;?></hostname>
+         <port>587</port>
+         <socketType>STARTTLS</socketType>
+         <username>%EMAILADDRESS%</username>
+         <authentication>password-cleartext</authentication>
+      </outgoingServer>
+
+      <enable visiturl="https://<?=$mailcow_hostname;?>/admin.php">
+         <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>
+         <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>
+      </enable>
+
+    </emailProvider>
+
+    <webMail>
+      <loginPage url="https://<?=$mailcow_hostname;?>/SOGo/" />
+    </webMail>
+</clientConfig>

+ 3 - 3
data/web/autodiscover.php

@@ -5,17 +5,17 @@ $config = array(
      'useEASforOutlook' => 'yes',
      'autodiscoverType' => 'activesync',
      'imap' => array(
-       'server' => 'MAILCOW_HOST.MAILCOW_DOMAIN',
+       'server' => $mailcow_hostname,
        'port' => '993',
        'ssl' => 'on',
      ),
      'smtp' => array(
-       'server' => 'MAILCOW_HOST.MAILCOW_DOMAIN',
+       'server' => $mailcow_hostname,
        'port' => '465',
        'ssl' => 'on'
      ),
      'activesync' => array(
-       'url' => 'https://MAILCOW_HOST.MAILCOW_DOMAIN/Microsoft-Server-ActiveSync'
+       'url' => 'https://' . $mailcow_hostname . '/Microsoft-Server-ActiveSync'
      )
 );
 // If useEASforOutlook == no, the autodiscoverType option will be replaced to imap.

+ 3 - 0
data/web/inc/vars.inc.php

@@ -12,6 +12,9 @@ $database_host = "mysql";
 $database_user = getenv('DBUSER');
 $database_pass = getenv('DBPASS');
 $database_name = getenv('DBNAME');
+
+// Other variables
+$mailcow_hostname = getenv('MAILCOW_HOSTNAME');
 date_default_timezone_set(getenv('TZ'));
 
 // Where to go after adding and editing objects

+ 1 - 0
docker-compose.yml

@@ -82,6 +82,7 @@ services:
         - DBNAME=${DBNAME}
         - DBUSER=${DBUSER}
         - DBPASS=${DBPASS}
+        - MAILCOW_HOSTNAME=${MAILCOW_HOSTNAME}
         - TZ=${TZ}
       restart: always
       networks: