Debian AutoMX

Aus Wiki
Zur Navigation springen Zur Suche springen

Allgemein

Thunderbird (ab Version 3.0) und MS Outlook (ab Version 2007) bieten die Möglichkeit, die Servereinstellungen automatisch einzurichten. Aber auch mobile Mailclients unter IOs und Android bieten diese Möglichkeit. Zu diesem Zweck versuchen sie bei der Einrichtung der Konten ein XML-File via HTTP bzw HTTPS downzuloaden, das die Servereinstellungen enthält (ohne das Userpasswort).

Um die Auslieferung der erforderlichen XML-Files kümmert sich AutoMX (Python Script) in Verbindung mit dem Apache Webserver. AutoMX ist nicht in den Debian Paketquellen enthalten, sodass es im Folgenden manuell installiert wird.

Outlook und Thunderbird erwarten zum Einen das XML-File unter unterschiedlicher Adresse, zum Anderen haben sie einen unterschiedlichen Aufbau. AutoMX antwortet je nach Client mit der korrekten XML-Filestruktur.


Voraussetzung


Installation

notwendige Debian Pakete

apt-get install python2.7 python-ipaddr python-lxml python-memcache python-dateutil libapache2-mod-python libapache2-mod-wsgi


AutoMX

mkdir /usr/local/src/automx
cd /usr/local/src/automx
wget http://automx.org/download/latest.tar.gz
tar xvf latest.tar.gz
cd automx*/src
mkdir /usr/local/lib/automx
cp automx_wsgi.py /usr/local/lib/automx
cp automx-test /usr/local/bin
cp -R automx /usr/lib/python2.7/´dist-packages/
cp conf/automx.conf /etc
cp conf/apache.conf.example /etc/apache2/sites-enabled/automx.conf
mkdir /var/log/automx
touch /var/log/automx/automx.log
chmod -R 777 /var/log/automx

Konfiguration

AutoMX

vi /etc/automx.conf

Im Bereich [automx] folgende Einstellungen vornehmen:

domains = *
logfile = /var/log/automx/automx.log     (Kommentarzeichen # entfernen)

Im Bereich [Default] folgende Einstellungen vornehmen:

account_name = Private Mail Server
account_name_short = Private Mail

Im Bereich [Global] folgende Einstellungen vornehmen:

smtp = yes
smtp_server = smtp.domain.org
smtp_port = 25

imap = yes
imap_server = imap.domain.org
imap_port = 993
imap_encryption = ssl
imap_auth = plaintext
imap_refresh_ttl = 6

pop = no

Den Bereich [example.com] durch [domain.org] ersetzen.

Falls weitere Maildomains von AutoMX behandelt werden sollen, können weitere Bereiche z.B.[domain2.org] angehängt werden. Falls andere Einstellungen als im Bereich [Global] erforderlich sind, könenn diese folgendermaßen angegeben werden:

[domain2.org]
backend = static
action = settings

smtp = yes
smtp_server = smtp.domain2.org
smtp_port = 25
smtp_encryption = starttls
smtp_auth = plaintext
smtp_refresh_ttl = 6
smtp_default = yes

imap = yes
imap_server = imap.domain2.org
imap_port = 993
imap_encryption = ssl
imap_auth = plaintext
imap_refresh_ttl = 6

pop = no
...


Apache

vi /etc/apache2/sites-enabled/automx.conf

Das File folgendermaßen abändern (domain anpassen, evtl. ServerAlias auskommentieren, falls mehrere domains behandelt werden sollen. evtl. mehrere ServerAlias Directiven einfügen):

  • Apache2.2:
# Example for autoconfig
<VirtualHost *:80>
  ServerName autoconfig.domain.org
  #ServerAlias autoconfig.domain2.org
  ServerAdmin webmaster@domain.org

  <IfModule mod_wsgi.c>
    WSGIScriptAlias /mail/config-v1.1.xml /usr/local/lib/automx/automx_wsgi.py
    <Directory "/usr/local/lib/automx">
      Order allow,deny
      Allow from all
    </Directory>
  </IfModule>
</VirtualHost>

# SSL example for autodiscover
<VirtualHost *:443>
 ServerName autodiscover.domain.org
 #ServerAlias autodiscover.domain2.org
 ServerAdmin webmaster@domain.org
 <IfModule mod_wsgi.c>
   WSGIScriptAlias /Autodiscover/Autodiscover.xml /usr/local/lib/automx/automx_wsgi.py
   WSGIScriptAlias /autodiscover/autodiscover.xml /usr/local/lib/automx/automx_wsgi.py
   <Directory "/usr/local/lib/automx">
     Order allow,deny
     Allow from all
   </Directory>
 </IfModule>

 # more ssl options ...
 SSLEngine on
 SSLProxyEngine On
 SSLCertificateFile /etc/ssl/CA/certs/wildcard.pem 
</VirtualHost>
  • Apache2.4:
# Example for autoconfig
<VirtualHost *:80>
  ServerName autoconfig.domain.org
  #ServerAlias autoconfig.domain2.org
  ServerAdmin webmaster@domain.org

  <IfModule mod_wsgi.c>
    WSGIScriptAlias /mail/config-v1.1.xml /usr/local/lib/automx/automx_wsgi.py
    <Directory "/usr/local/lib/automx">
      Require all granted
    </Directory>
  </IfModule>
</VirtualHost>

# SSL example for autodiscover
<VirtualHost *:443>
 ServerName autodiscover.domain.org
 #ServerAlias autodiscover.domain2.org
 ServerAdmin webmaster@domain.org
 <IfModule mod_wsgi.c>
   WSGIScriptAlias /Autodiscover/Autodiscover.xml /usr/local/lib/automx/automx_wsgi.py
   WSGIScriptAlias /autodiscover/autodiscover.xml /usr/local/lib/automx/automx_wsgi.py
   <Directory "/usr/local/lib/automx">
     Require all granted
   </Directory>
 </IfModule>

 # more ssl options ...
 SSLEngine on
 SSLProxyEngine On
 SSLCertificateFile /etc/ssl/CA/certs/wildcard.pem 
</VirtualHost>


Funktionstest

Im Lieferumfang von AutoMX befindet sich ein Testprogramm, um das Setup zu testen:

automx-test tux@domain.org

Die Ausgabe sollte folgendermaßen aussehen: Testing Autoconfig ...

Connecting to http://autoconfig.domain.org/mail/config-v1.1.xml?emailaddress=tux@domain.org ...

  HTTP/1.1 200 OK
  Date: Sun, 31 Mar 2013 16:56:39 GMT
  Server: Apache/2.2.16 (Debian)
  Content-Length: 880
  Vary: Accept-Encoding
  Keep-Alive: timeout=15, max=100
  Connection: Keep-Alive
  Content-Type: text/xml
<?xml version='1.0' encoding='utf-8'?>
<clientConfig version="1.1">
  <emailProvider id="domain.org">
    <domain>domain.org</domain>
    <displayName>Private Mail Server</displayName>
    <displayShortName>Private Mail</displayShortName>
    <outgoingServer type="smtp">
      <hostname>smtp.domain.org</hostname>
      <port>25</port>
      <socketType>STARTTLS</socketType>
      <authentication>password-cleartext</authentication>
      <username>tux</username>
      <useGlobalPreferredServer>yes</useGlobalPreferredServer>
    </outgoingServer>
    <incomingServer type="imap">
      <hostname>imap.domain.org</hostname>
      <port>993</port>
      <socketType>SSL</socketType>
      <authentication>password-cleartext</authentication>
      <username>tux</username>
    </incomingServer>
  </emailProvider>
</clientConfig>

Testing Autodiscover (Microsoft Outlook(tm)) ...
Connecting to https://autodiscover.domain.org/autodiscover/autodiscover.xml ...

  HTTP/1.1 200 OK
  Date: Sun, 31 Mar 2013 16:56:40 GMT
  Server: Apache/2.2.16 (Debian)
  Content-Length: 1045
  Vary: Accept-Encoding
  Keep-Alive: timeout=15, max=100
  Connection: Keep-Alive
  Content-Type: text/xml
<?xml version='1.0' encoding='utf-8'?>
<Autodiscover xmlns="http://schemas.microsoft.com/exchange/autodiscover/responseschema/2006">
  <Response xmlns="http://schemas.microsoft.com/exchange/autodiscover/outlook/responseschema/2006a">
    <Account>
      <AccountType>email</AccountType>
      <Action>settings</Action>
      <Protocol>
        <Type>SMTP</Type>
        <Server>smtp.domain.org</Server>
        <Port>25</Port>
        <DomainRequired>off</DomainRequired>
        <LoginName>tux</LoginName>
        <SPA>off</SPA>
        <Encryption>TLS</Encryption>
        <AuthRequired>on</AuthRequired>
        <TTL>6</TTL>
      </Protocol>
      <Protocol>
        <Type>IMAP</Type>
        <Server>imap.domain.org</Server>
        <Port>993</Port>
        <DomainRequired>off</DomainRequired>
        <LoginName>tux</LoginName>
        <SPA>off</SPA>
        <Encryption>SSL</Encryption>
        <AuthRequired>on</AuthRequired>
        <TTL>6</TTL>
      </Protocol>
    </Account>
  </Response>
</Autodiscover>

Testing Autodiscover (mobilesync) ...
Connecting to https://autodiscover.domain.org/autodiscover/autodiscover.xml ...

  HTTP/1.1 200 OK
  Date: Sun, 31 Mar 2013 16:56:40 GMT
  Server: Apache/2.2.16 (Debian)
  Content-Length: 512
  Vary: Accept-Encoding
  Keep-Alive: timeout=15, max=100
  Connection: Keep-Alive
  Content-Type: text/xml
<?xml version='1.0' encoding='utf-8'?>
<Autodiscover xmlns="http://schemas.microsoft.com/exchange/autodiscover/responseschema/2006">
  <Response xmlns="http://schemas.microsoft.com/exchange/autodiscover/mobilesync/responseschema/2006">
    <Culture>en:us</Culture>
    <User>
      <EmailAddress>tux@domain.org</EmailAddress>
    </User>
    <Action>
      <Settings>
        <Server>
          <Type>MobileSync</Type>
        </Server>
      </Settings>
    </Action>
  </Response>
</Autodiscover>