Mailman

提供: ArchWiki
2023年10月28日 (土) 19:32時点におけるKgx (トーク | 投稿記録)による版 (→‎REST API: 翻訳)
ナビゲーションに移動 検索に移動

Mailman はメーリングリスト管理システムです。メールサーバーと組み合わせて使用します。

インストール

mailman3 パッケージをインストールします。

ノート: mailman3 は近い将来 mailman に置き換わる予定です。両方のアプリケーションが /var/lib/mailman をステートディレクトリ、mailman ユーザーとして使うので、現在衝突していて、一緒にインストールすることはできません。

Mailman は Postorius (設定用) と Hyperkitty (アーカイブ用)と一緒に使うことができます。

ノート: Mailman は専用の mailman ユーザーとして実行されます。したがって、mailman 実行ファイルは、mailman ユーザーとして実行する必要があります。

設定

Mailman の設定はすべて /etc/mailman.cfg で行われます。全ての可能な設定オプションとデフォルトの設定を説明するスキーマは /usr/lib/python3.8/site-packages/mailman/config/schema.cfg に格納されています。

また、コマンドラインからも設定にアクセスすることができます。mailman ユーザーとして (例: sudosu を使って) 以下のコマンドを実行します。

[mailman]$ mailman conf

データベース

Mailman はデフォルトで、/var/lib/mailman/data/ の SQLite データベース を使用します。 ですが、MariaDB または PostgreSQL を使用するように設定できます。

SQLite

SQLite データベースのデフォルトの場所はすでに schema.cfg に反映されているため、Mailman で設定する必要はありません。

/etc/mailman.cfg
[database]
url: sqlite:////var/lib/mailman/data/mailman.db

MariaDB

python-pymysql パッケージを インストール し、MariaDB にデータベースを設定します。

/etc/mailman.cfg
[database]
class: mailman.database.mysql.MySQLDatabase
url: mysql+pymysql://myuser:mypassword@mymysqlhost/mailman?charset=utf8&use_unicode=1

PostgreSQL

python-psycopg2 パッケージを インストール し、PostgreSQL を使用してデータベースを作成します。

/etc/mailman.cfg
[database]
class: mailman.database.postgresql.PostgreSQLDatabase
url: postgres://myuser:mypassword@mypghost/mailman

REST API

Mailman は、設定の [webservice] セクションの設定に基づいて REST API を公開します。admin_useradmin_pass のデフォルト値を必ず置き換えてください (以下の例の値は使用しないでください)

/etc/mailman.cfg
[webservice]
admin_user: my_new_admin_user_name
admin_pass: my_new_admin_user_password

ARC

By default DMARC and DKIM are disabled. The configuration takes place in the [ARC] section of the configuration file. Make sure to set necessary values and read the documentation about the defaults.

/etc/mailman.cfg
[ARC]
enabled: yes
authserv_id: mailserver.tld
trusted_authserv_ids: subdomain.mailserver.tld, other.mailserver.tld
privkey: /path/to/privatekey.pem
selector: test
domain: mailserver.tld

MTA

To connect a mail-transfer-agent (MTA), it is necessary to configure the [mta] section in the configuration file. Upstream documentation covers examples for postfix, exim and sendmail, but other MTAs are technically possible.

Postfix

To connect to a local postfix instance the following configuration section can be used:

/etc/mailman.cfg
[mta]
incoming: mailman.mta.postfix.LMTP
outgoing: mailman.mta.deliver.deliver
lmtp_host: mail.example.com
lmtp_port: 8024
smtp_host: mail.example.com
smtp_port: 25

The postfix configuration has to be extended to ensure compatibility (see upstream notes).

/etc/postfix/main.cf

[..]
recipient_delimiter = +
unknown_local_recipient_reject_code = 550
owner_request_special = no
[..]

Additionally, postfix needs to be made aware of mailman's transport maps. Depending on the postfix configuration these may look similar to the following.

ノート: The following examples assume that existing values for transport_maps, local_recipient_maps, relay_domains, virtual_mailbox_domains and virtual_alias_maps are merged with the additional values.
/etc/postfix/main.cf

[..]
transport_maps = hash:/var/lib/mailman/data/postfix_lmtp
local_recipient_maps = hash:/var/lib/mailman/data/postfix_lmtp
relay_domains = hash:/var/lib/mailman/data/postfix_domains
[..]

If postmap is not directly accessible by mailman for creating the default hash-based alias maps, it is possible to generate regular expression based alias maps instead. To overwrite the default Python-class based configuration, mailman allows the use of a configuration file. Create the following file:

/etc/postfix-mailman.cfg
[postfix]
postmap_command: /usr/bin/postmap
transport_file_type: regex

Add the file to the [mta] section in mailman's configuration file.

/etc/mailman.cfg
[mta]
[..]
configuration: /etc/postfix-mailman.cfg

Afterwards the regexp based exports can then be used in the postfix configuration.

/etc/postfix/main.cf

[..]
transport_maps = regexp:/var/lib/mailman/data/postfix_lmtp
local_recipient_maps = regexp:/var/lib/mailman/data/postfix_lmtp
relay_domains = regexp:/var/lib/mailman/data/postfix_domains
[..]

ノート: Make sure to create the new alias maps after changing their type (e.g. from hash to regexp): [mailman]$ mailman aliases

To connect to a local postfix instance with a virtual mail setup, first set an alias domain. Afterwards alter the respective configuration.

/etc/postfix/main.cf

[..]
local_recipient_maps = regexp:/var/lib/mailman/data/postfix_lmtp
transport_maps = regexp:/var/lib/mailman/data/postfix_lmtp
virtual_mailbox_domains = regexp:/var/lib/mailman/data/postfix_domains
virtual_alias_maps = regexp:/var/lib/mailman/data/postfix_vmap
[..]

起動

Enable and start mailman3.service.

Several systemd services with timers exist, taking care of various aspects of the list management:

  • mailman3-digests.timer: for sending out daily digests to subscribers
  • mailman3-gatenews.timer: for hourly polling of NNTP servers for news
  • mailman3-notify.timer: for sending out daily notifications to admins about pending requests

セットアップ

メールサーバとの統合

Integrate with Hyperkitty

Mailman does not automatically archive mails on its own. The Hyperkitty web application is used for this purpose. Based on a plugin, mailman is able to send mails to a Hyperkitty instance for archival.

インストール the mailman3-hyperkitty package and configure /etc/mailman-hyperkitty.cfg.

/etc/mailman-hyperkitty.cfg
[general]
base_url: https://example.tld/hyperkitty/
api_key: super_secret_password

Afterwards, make mailman aware of the plugin:

/etc/mailman.cfg
[archiver.hyperkitty]
class: mailman_hyperkitty.Archiver
enable: yes
configuration: /etc/mailman-hyperkitty.cfg

ヒントとテクニック

mailman 3.0 未満からのマイグレート

Mailman offers the possibility of importing mailman < 3.0 based list databases (config.pck). Run the following command as the mailman user (e.g. using sudo or su):

[mailman]$ mailman import21 LISTSPEC PICKLE_FILE

Here, LISTSPEC represents a fully-qualified name of a list to import (e.g. list@example.com) and PICKLE_FILE the path to the list's config.pck file.

ノート: The mailman2 list to be imported must already exist on the target mailman instance.

REST API

Mailman exposes a REST API, which can be interfaced using custom tooling, based on python-mailmanclient.

参照