public
nobgit
read
NobMail
Based on mailcow: dockerized
Languages
Repository composition by tracked source files.
PHP
49%
JavaScript
35%
HTML
9%
CSS
4%
Shell
2%
Python
1%
Lua
0%
Perl
0%
Ruby
0%
SCSS
0%
Create file
Wiki Documentation
Clone
https://nobgit.com/orgs/nobgit/nobmail.git
ssh://[email protected]:2222/orgs/nobgit/nobmail.git
Commit
Add autodiscover and autoconfig
49e09d3c
data/conf/nginx/site.conf | 10 ++++++-
data/web/autoconfig.php | 69 +++++++++++++++++++++++++++++++++++++++++++++++
data/web/autodiscover.php | 6 ++---
data/web/inc/vars.inc.php | 3 +++
docker-compose.yml | 1 +
5 files changed, 85 insertions(+), 4 deletions(-)
create mode 100644 data/web/autoconfig.php
Diff
diff --git a/data/conf/nginx/site.conf b/data/conf/nginx/site.conf
index 57d9c9bc..07578a4c 100644
--- a/data/conf/nginx/site.conf
+++ b/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;
diff --git a/data/web/autoconfig.php b/data/web/autoconfig.php
new file mode 100644
index 00000000..4fd03474
--- /dev/null
+++ b/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>
diff --git a/data/web/autodiscover.php b/data/web/autodiscover.php
index 45b738de..a503b80c 100644
--- a/data/web/autodiscover.php
+++ b/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.
diff --git a/data/web/inc/vars.inc.php b/data/web/inc/vars.inc.php
index 6f52b969..0c716b38 100644
--- a/data/web/inc/vars.inc.php
+++ b/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
diff --git a/docker-compose.yml b/docker-compose.yml
index 3f4f21af..b91c5516 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -82,6 +82,7 @@ services:
- DBNAME=${DBNAME}
- DBUSER=${DBUSER}
- DBPASS=${DBPASS}
+ - MAILCOW_HOSTNAME=${MAILCOW_HOSTNAME}
- TZ=${TZ}
restart: always
networks: