= Mailman Infrastructure SOP

== Contact Information

Owner::
  Fedora Infrastructure Team
Contact::
  #fedora-admin, sysadmin-main, sysadmin-tools, sysadmin-hosted
Servers::
  mailman01, mailman01.stg
Purpose::
  Provides mailing list services.

== Description

Mailing list services for Fedora projects are located on the
mailman01.iad2.fedoraproject.org server.

== Common Tasks

=== Creating a new mailing list

* Log into mailman01
* `sudo -u mailman mailman3 create <listname>@lists.fedora(project|hosted).org --owner <username>@fedoraproject.org --notify`
+
[IMPORTANT]
====
Please make sure to add a valid description to the newly created list.
(to avoid [no description available] on listinfo index)
====

=== Adding user as admin

. Log in to db01 server
. Start the postgreSQL console
+
``sudo -u postgres psql``
+
. Connect to hyperkitty DB
+
``\connect hyperkitty``
+
. Add admin permissions to user
** By username
+
``UPDATE auth_user SET is_staff = TRUE, is_superuser = TRUE WHERE username=<username>;``
+
** By email (only primary mail is used)
+
``UPDATE auth_user SET is_staff = TRUE, is_superuser = TRUE WHERE email=<email>;``


=== Accessing admin page in mailman

Admin page will allow you to change some of the settings that are not able to be changed
anywhere else. The admin page could be accessed link:https://lists.fedoraproject.org/django-admin
or link:https://lists.stg.fedoraproject.org/django-admin for staging.

[NOTE]
====
You need to be added as admin to mailman to access the admin console.
====

== Deployment

In case of new deployment of mailman in infrastructure, there are few tasks
that need to be done manually.

=== Migrating social accounts from OpenID Fedora to OpenIDC

This needs to be done only once when you update from old OpenID Fedora auth provider
to OpenIDC version. Doing this will correctly map the old accounts to new auth provider.

. Log into mailman01
. ``cd /srv/webui/bin/``
. ``python migrate_fedora_auth.py``
+
This script does nothing if the users were already migrated.

== Removing content from archives

We don't.

It's not easy to remove content from the archives and it's generally
useless as well because the archives are often mirrored by third parties
as well as being in the INBOXs of all of the people on the mailing list
at that time. Here's an example message to send to someone who requests
removal of archived content:

....
Greetings,

We're sorry to say that we don't remove content from the mailing list archives.
Doing so is a non-trivial amount of work and usually doesn't achieve anything
because the content has already been disseminated to a wide audience that we do
not control.  The emails have gone out to all of the subscribers of the mailing
list at that time and also (for a great many of our lists) been copied by third
parties (for instance: http://markmail.org and http://gmane.org).

Sorry we cannot help further,

 Mailing lists and their owners
....

== Checking Membership

Are you in need of checking who owns a certain mailing list without
having to search around on list's frontpages?

Mailman has a nice tool that will help us list members by type.

Get a full list of all the mailing lists hosted on the server:

....
sudo -u mailman mailman3 lists
....

Get the list of regular members for example@example.com:

....
sudo -u mailman mailman3 members example@example.com
....

Get the list of owners for example@example.com:

....
sudo -u mailman mailman3 members -R owner example@example.com
....

Get the list of moderators for example@example.com:

....
sudo -u mailman mailman3 members -R moderator example@example.com
....

== How to delete a mailing list

Delete a list, but keep the archives:

....
sudo -u mailman mailman3 remove <listname>
....

== Troubleshooting and Resolution

=== List Administration

Specific users are marked as 'site admins' in the database.

Please file an issue if you feel you need to have this access.

=== Restart Procedure

If the server needs to be restarted mailman should come back on it's
own. Otherwise each service on it can be restarted:

....
systemctl restart mailman3
systemctl restart postfix
systemctl restart mailmanweb
....

=== Log locations

Most of the logs are located in `/var/log/mailman3/`. In case you are looking for
postfix logs, they could be found in `/var/log/maillog`.

=== Known error messages

These are the error messages that are common in mailman3 logs:

* `NNTP error for list <listname>`
+
We don't have NNTP server and this couldn't be disabled in mailman3, so you
can saw this error in logs, but it could be ignored.

=== Memory spikes

Mailman gunicorn http server sometimes has a memory spikes that could lead to some services
being killed by OOM killer. In this case just restart the mailman. See <<Restart Procedure>>.
