跳至內容

Mailman

出自 Arch Linux 中文维基

本文或本節需要翻譯。要貢獻翻譯,請訪問簡體中文翻譯團隊

附註: 需要翻譯。(在 Talk:Mailman# 中討論)

Mailman 是一個郵件列表管理系統。它與郵件伺服器結合使用。

安裝

[編輯 | 編輯原始碼]

安裝mailman3軟體包。

Mailman 可與Postorius(用於配置)和Hyperkitty(用於存檔)結合使用。

注意:Mailmanmailman專用用戶的身份運行,因此任何對mailman可執行文件的調用都必須以mailman用戶的身份進行。

配置

[編輯 | 編輯原始碼]

All configuration for Mailman takes place in /etc/mailman.cfg. The schema explaining all possible configuration options and setting the defaults is stored in /usr/lib/python3.8/site-packages/mailman/config/schema.cfg.

The configuration is also accessible via the command line. Run the following command as the mailman user (e.g. using sudo or su):

[mailman]$ mailman conf

資料庫

[編輯 | 編輯原始碼]

Mailman by default uses an SQLite database in /var/lib/mailman/data/, but can be configured to use MariaDB or PostgreSQL.

SQLite

[編輯 | 編輯原始碼]

The default location for the SQLite database is already reflected in the schema.cfg and therefore does not have to be set in Mailman's configuration.

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

MariaDB

[編輯 | 編輯原始碼]

Install the python-pymysql package and configure a database on MariaDB.

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

PostgreSQL

[編輯 | 編輯原始碼]

Install the python-psycopg2 package and create a database using PostgreSQL.

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

REST API

[編輯 | 編輯原始碼]

Mailman exposes its REST API based on the settings in the [webservice] section of the configuration. Make sure to replace the default values for admin_user and admin_pass (do not use the example values below).

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

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

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
[..]

運行

[編輯 | 編輯原始碼]

啟用啟動 mailman3.service

有幾個systemd定時器服務,負責列表管理的各個方面:

  • mailman3-digests.timer:用於向訂閱者發送每日摘要。
  • mailman3-gatenews.timer:每小時輪詢NNTP伺服器以獲取新聞
  • mailman3-notify.timer:用於每天向管理員發送待處理請求的通知。

安裝

[編輯 | 編輯原始碼]

與郵件伺服器集成

[編輯 | 編輯原始碼]

這篇文章的某些內容需要擴充。

原因:Example for setup with mail server (based on upstream documentation). (在 Talk:Mailman 中討論)

與 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.

Install 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 可以導入基於 mailman < 3.0 的列表資料庫(config.pck)。以 mailman 用戶身份(例如使用 sudosu )運行以下命令:

[mailman]$ mailman import21 LISTSPEC PICKLE_FILE

這裡,LISTSPEC 表示要導入的列表的全稱(例如 list@example.com),PICKLE_FILE 表示列表的 config.pck 文件路徑。

注意:要導入的 mailman2 列表必須已經存在於目標 mailman 實例中。

REST API

[編輯 | 編輯原始碼]

Mailman 公開了REST API,可使用基於 python-mailmanclient 的自定義工具進行連接。

參見

[編輯 | 編輯原始碼]