Skip to main content

Autoconfigure mail clients from Modoboa

Project description

modoboa-automua

Autoconfigure mail clients from Modoboa.

This extension is based on automx to provide methods for automated mailbox configuration from Microsoft's Autodiscover and Mozilla's Autoconfig. It extends Modoboa to configure the server name to use for each domain from its administration interface, and to return the appropriate response to the MUA.

Requirements

  • Python 3 (>= 3.7)
  • Modoboa, deployed with the installer or manually

Installation

  1. Activate the virtual environment in which Modoboa is installed.
  2. Install this extension from PyPi:
    (env)$ pip install modoboa-automua
    
  3. Add this extension to the installed applications in your instance's settings:
    MODOBOA_APPS = (
        "modoboa",
        # ...
        # Modoboa extensions here.
        "modoboa_automua",
    )
    
  4. Update your database and collect the static files:
    (env)$ ./manage.py migrate
    (env)$ ./manage.py collectstatic
    

Finally, restart the Python process which is running Modoboa.

Usage

Once this extension is installed, you will need to configure either the server name to return for each domain - see AUTOMUA_DEFAULT_SERVER_NAME - or to configure each domain from the Modoboa administration - through the MUA tab.

Then, you will have to adjust your Web server to serve the autoconfig.* and autodiscover.* domains either by your Modoboa instance or with a new dedicated WSGI application - see AUTOMUA_SERVE_FRONTEND_ROUTES.

Configuration

The following settings are available to customize this extension.

AUTOMUA_DEFAULT_SERVER_NAME

The server name to use for all the domains which are configured to use the default values. By default, or if it is empty, the autoconfiguration will not be available for those domains.

For example:

AUTOMUA_DEFAULT_SERVER_NAME = "mx.example.org"

AUTOMUA_SERVE_FRONTEND_ROUTES

By default, this is True and views for mail clients will be served by the Modoboa application.

In production, you would rather like to serve those routes by a dedicated WSGI application to preserve the security of the Modoboa application - and prevent any changes to ALLOWED_HOST. To proceed, you will have to:

  1. Set AUTOMUA_SERVE_FRONTEND_ROUTES to False in the settings file of your Modoboa instance.

  2. Create a new folder - e.g. named automua - where the manage.py file of your instance is located, with the following files inside:

    • __init__.py, an empty file
    • settings.py, which could just contain the following lines:
      from modoboa_automua.frontend.settings import *  # noqa
      
      # Define SECRET_KEY, SITE_ID and DATABASES with the same values than
      # the one in the settings file of your Modoboa instance.
      
      # Optionaly, set the default server name:
      #AUTOMUA_DEFAULT_SERVER_NAME = "mx.example.org"
      
    • wsgi.py, with the following content - replace automua with the name of your folder if you have chosen a different one:
      import os
      
      from django.core.wsgi import get_wsgi_application
      
      os.environ.setdefault("DJANGO_SETTINGS_MODULE", "automua.settings")
      
      application = get_wsgi_application()
      
  3. Serve a new WSGI application with the newly created wsgi.py file as the entry point on all the required domains - e.g. autoconfig.* and autodiscover.*.

AUTOMUA_SERVER_SERVICES

You can configure the available services of your mail server which will be returned to the MUA for all domains. A service is composed by:

By default, all protocols in both SSL and STARTTLS are returned - SSL ones have higher priority though. They are defined in an ordered list by modoboa_automua.DEFAULT_SERVER_SERVICES.

For example, to expose only protocols in SSL:

from modoboa_automua import Service, ServiceSecurity, ServiceType

AUTOMUA_SERVER_SERVICES = (
    Service(ServiceType.POP, 995, ServiceSecurity.SSL),
    Service(ServiceType.IMAP, 993, ServiceSecurity.SSL),
    Service(ServiceType.SMTP, 465, ServiceSecurity.SSL),
)

Development

To setup a development environment, clone this repository and follow the installation steps but replace the installation from PyPi by:

(env)$ pip install -e .[test]

The Python code is formatted and linted thanks to flake8, isort and black. To ease the use of this tools, the following commands are available:

  • make lint: check the Python code syntax and imports order
  • make format: fix the Python code syntax and imports order

License

This extension is mainly developed by Cliss XXI and licensed under the AGPLv3+. Any contribution is welcome!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

modoboa-automua-1.0.0.tar.gz (33.9 kB view hashes)

Uploaded Source

Built Distribution

modoboa_automua-1.0.0-py3-none-any.whl (26.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page