Przeglądaj źródła

Add support for Thunderbird automatic configuration

Resolves #114
Lorenzo Villani 10 lat temu
rodzic
commit
8959f1c183

+ 2
- 0
README.textile Wyświetl plik

@@ -32,6 +32,7 @@ What do you get if you point this thing at a VPS? All kinds of good stuff!
32 32
 * "SMTP":https://en.wikipedia.org/wiki/Simple_Mail_Transfer_Protocol over SSL via Postfix, including a nice set of "DNSBLs":https://en.wikipedia.org/wiki/DNSBL to discard spam before it ever hits your filters.
33 33
 * Webmail via "Roundcube":http://www.roundcube.net/.
34 34
 * Mobile push notifications via "Z-Push":http://z-push.sourceforge.net/soswp/index.php?pages_id=1&t=home.
35
+* Email client "automatic configuration":https://developer.mozilla.org/en-US/docs/Mozilla/Thunderbird/Autoconfiguration.
35 36
 * Jabber/"XMPP":http://xmpp.org/ instant messaging via "Prosody":http://prosody.im/.
36 37
 * An RSS Reader via "Selfoss":http://selfoss.aditu.de/.
37 38
 * Virtual domains for your email, backed by "PostgreSQL":http://www.postgresql.org/.
@@ -191,6 +192,7 @@ If you've just bought a new domain name, point it at "Linode's DNS Manager":http
191 192
 Create an @A@ records which point to your server IP for:
192 193
  * @example.com@
193 194
  * @mail.example.com@
195
+ * @autoconfig.example.com@ (for email client automatic configuration)
194 196
  * @read.example.com@ (for wallabe)
195 197
  * @news.example.com@ (for selfoss)
196 198
  * @cloud.example.com@ (for owncloud)

+ 22
- 0
roles/mailserver/tasks/autoconfig.yml Wyświetl plik

@@ -0,0 +1,22 @@
1
+---
2
+#
3
+# Autoconfig XML file for email clients
4
+# https://developer.mozilla.org/en-US/docs/Mozilla/Thunderbird/Autoconfiguration
5
+#
6
+
7
+- name: Create directory for mail autoconfiguration virtualhost
8
+  file: state=directory path=/var/www/autoconfig group=www-data owner=www-data
9
+
10
+- name: Create directory holding the autoconfig XML file
11
+  file: state=directory path=/var/www/autoconfig/mail group=www-data owner=www-data
12
+
13
+- name: Create the autoconfig XML file
14
+  template: src=var_www_autoconfig_mail_config-v1.1.j2 dest=/var/www/autoconfig/mail/config-v1.1.xml group=www-data owner=www-data
15
+
16
+- name: Configure the mail autoconfiguration virtualhost
17
+  template: src=etc_apache2_sites-available_autoconfig.j2 dest=/etc/apache2/sites-available/autoconfig.conf group=root owner=root
18
+  notify: restart apache
19
+
20
+- name: Enable the mail autoconfiguration virtualhost
21
+  command: a2ensite autoconfig.conf creates=/etc/apache2/sites-enabled/autoconfig.conf
22
+  notify: restart apache

+ 2
- 1
roles/mailserver/tasks/main.yml Wyświetl plik

@@ -4,4 +4,5 @@
4 4
 - include: dspam.yml tags=dspam
5 5
 - include: solr.yml tags=solr
6 6
 - include: checkrbl.yml tags=checkrbl
7
-- include: z-push.yml tags=zpush
7
+- include: z-push.yml tags=zpush
8
+- include: autoconfig.yml tags=autoconfig

+ 34
- 0
roles/mailserver/templates/etc_apache2_sites-available_autoconfig.j2 Wyświetl plik

@@ -0,0 +1,34 @@
1
+# NOTE: We don't permanently redirect clients to the HTTPS address because some clients, like
2
+# Thunderbird, dont't follow redirections to the HTTPS URL.
3
+#
4
+# Additionally, documentation doesn't say whether the XML file should be served over either HTTP,
5
+# HTTPS or both, even though only the former is mentioned. Still, we allow clients to choose
6
+# between HTTP and HTTPS transports.
7
+
8
+<VirtualHost *:80>
9
+
10
+    ServerName {{ mail_server_autoconfig_hostname }}
11
+
12
+    DocumentRoot            "/var/www/autoconfig"
13
+    Options                 -Indexes
14
+
15
+    HostnameLookups         Off
16
+</VirtualHost>
17
+
18
+<VirtualHost *:443>
19
+    ServerName {{ mail_server_autoconfig_hostname }}
20
+
21
+    SSLEngine on
22
+    SSLProtocol ALL -SSLv2
23
+    SSLHonorCipherOrder On
24
+    SSLCipherSuite ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AES:RSA+3DES:!ADH:!AECDH:!MD5:!DSS
25
+    SSLCertificateFile      /etc/ssl/certs/wildcard_public_cert.crt
26
+    SSLCertificateKeyFile   /etc/ssl/private/wildcard_private.key
27
+    SSLCACertificateFile    /etc/ssl/certs/wildcard_ca.pem
28
+    Header add Strict-Transport-Security "max-age=15768000; includeSubdomains"
29
+
30
+    DocumentRoot            "/var/www/autoconfig"
31
+    Options                 -Indexes
32
+
33
+    HostnameLookups         Off
34
+</VirtualHost>

+ 29
- 0
roles/mailserver/templates/var_www_autoconfig_mail_config-v1.1.j2 Wyświetl plik

@@ -0,0 +1,29 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<clientConfig version="1.1">
3
+    <emailProvider id="{{ domain }}">
4
+        <domain>{{ domain }}</domain>
5
+        <displayName>{{ domain }}</displayName>
6
+        <displayShortName>{{ domain }}</displayShortName>
7
+        <incomingServer type="imap">
8
+            <hostname>{{ mail_server_hostname }}</hostname>
9
+            <port>993</port>
10
+            <socketType>SSL</socketType>
11
+            <authentication>password-cleartext</authentication>
12
+            <username>%EMAILADDRESS%</username>
13
+        </incomingServer>
14
+        <incomingServer type="pop3">
15
+            <hostname>{{ mail_server_hostname }}</hostname>
16
+            <port>995</port>
17
+            <socketType>SSL</socketType>
18
+            <authentication>password-cleartext</authentication>
19
+            <username>%EMAILADDRESS%</username>
20
+        </incomingServer>
21
+        <outgoingServer type="smtp">
22
+            <hostname>{{ mail_server_hostname }}</hostname>
23
+            <port>587</port>
24
+            <socketType>SSL</socketType>
25
+            <authentication>password-cleartext</authentication>
26
+            <username>%EMAILADDRESS%</username>
27
+        </outgoingServer>
28
+    </emailProvider>
29
+</clientConfig>

+ 12
- 0
tests.py Wyświetl plik

@@ -39,6 +39,18 @@ class WebTests(unittest.TestCase):
39 39
         # 403 - Since there is no documents in the blog directory
40 40
         self.assertEquals(r.status_code, 403)
41 41
 
42
+    def test_mail_autoconfig_http_and_https(self):
43
+        """Email autoconfiguration XML file is accessible over both HTTP and HTTPS"""
44
+
45
+        # Test getting the file over HTTP and HTTPS
46
+        for proto in ['http', 'https']:
47
+            r = requests.get(proto + '://autoconfig.' + TEST_SERVER + '/mail/config-v1.1.xml')
48
+
49
+            # 200 - We should see the XML file
50
+            self.assertEquals(r.status_code, 200)
51
+            self.assertIn('application/xml', r.headers['Content-Type'])
52
+            self.assertIn('clientConfig version="1.1"', r.content)
53
+
42 54
     def test_webmail_http(self):
43 55
         """Webmail is redirecting to https and displaying login page"""
44 56
         r = requests.get('http://mail.' + TEST_SERVER)

+ 1
- 0
vars/defaults.yml Wyświetl plik

@@ -51,6 +51,7 @@ znc_version: 1.4
51 51
 
52 52
 # mailserver
53 53
 mail_server_hostname: "mail.{{ domain }}"
54
+mail_server_autoconfig_hostname: "autoconfig.{{ domain }}"
54 55
 mail_db_username: mailuser
55 56
 # mail_db_password: (required)
56 57
 mail_db_database: mailserver

Ładowanie…
Anuluj
Zapisz