Skip to content

Instantly share code, notes, and snippets.

@plepe
Last active June 15, 2023 11:01
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save plepe/dab22fdbfec63d8632709065890124a3 to your computer and use it in GitHub Desktop.
Save plepe/dab22fdbfec63d8632709065890124a3 to your computer and use it in GitHub Desktop.
Installing Mailman3 on Ubuntu 18.04 with MariaDB

Installing Mailman3 on Ubuntu 18.04 with MariaDB

Installing Mailman3 on Ubuntu 18.04 was surprisingly difficult, that's why I want to share my experiences with the world. Here you are:

First install MariaDB

apt install mariadb-server

Add to [mysqld] in /etc/mysql/mariadb.conf.d/50-server.cnf:

innodb_file_format = Barracuda
innodb_default_row_format = dynamic
innodb_file_per_table = 1
innodb_large_prefix = 1

Restart MariaDB:

systemctl restart mariadb

Grant database access rights:

mysql -uroot
grant all privileges on mailman3.* to mailman3@localhost identified by 'securepassword';
grant all privileges on mailman3web.* to mailman3@localhost identified by 'securepassword';

Install Mailman3

apt install mailman3-full dbconfig-mysql python-pymysql python3-pymysql
  • Configure mailman3 and mailman3-web:
    • Configure database with dbconfig-common -> yes
    • MySQL application password: securepassword
    • Connection method: Unix socket
    • Database name: mailman3
    • Mysql username: mailman3@localhost
    • Mysql administrative user: root
    • Add HyperKitty: Yes

Add the following lines to /etc/postfix/main.cf:

transport_maps = hash:/var/lib/mailman3/data/postfix_lmtp
local_recipient_maps = hash:/var/lib/mailman3/data/postfix_lmtp
relay_domains = hash:/var/lib/mailman3/data/postfix_domains

Restart postfix:

systemctl restart postfix

Install Apache2 for web access

apt install apache2
ln -s /etc/mailman3/apache.conf /etc/apache2/conf-enabled/mailman3.conf
a2enmod proxy_uwsgi
systemctl restart apache2
  • In a browser, open http://localhost/mailman3
  • Create a new user (admin)
  • Hopefully receive the confirmation email, open the link (you might need to replace https://localhost by http://localhost).

As the newly created user is not an admin user, use the MySQL database to give administration rights:

mysql -uroot mailman3web
update auth_user set is_superuser=true, is_staff=true where username='admin';

LDAP authentication (optional)

Edit /etc/mailman3/mailman-web.py, add the following lines:

AUTH_LDAP_SERVER_URI = "ldap://ldap.example.com"
AUTH_LDAP_USER_DN_TEMPLATE = "uid=%(user)s,ou=people,dc=example,dc=com"
AUTH_LDAP_BIND_DN = ""
AUTH_LDAP_BIND_PASSWORD = ""
AUTH_LDAP_USER_ATTR_MAP = {"first_name": "givenName", "last_name": "sn", "email": "mail"}

AUTHENTICATION_BACKENDS = (
    'django.contrib.auth.backends.ModelBackend',
    'django_auth_ldap.backend.LDAPBackend',
)

Install & Restart:

apt install python-django-auth-ldap
systemctl restart mailman3-web
  • If you want to disable the Fedora login button, uncomment the line 'django_mailman3.lib.auth.fedora' of the INSTALLED_APPS parameter in /etc/mailman3/mailman-web.conf.

  • If you want to disable sign-up, add the following lines to /etc/mailman3/mailman-web.conf (TODO: this still shows a 'Sign up' link and will produce a 500 Internal Server Error on click; didn't find a disable yet).

ACCOUNT_FORMS = {
    'signup': False
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment