Mailman
Mailman 是一个邮件列表管理系统。它与邮件服务器结合使用。
Mailman 可与Postorius(用于配置)和Hyperkitty(用于存档)结合使用。
mailman专用用户的身份运行,因此任何对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.
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
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
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
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.
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.
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 [..]
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 [..]
有几个systemd定时器服务,负责列表管理的各个方面:
-
mailman3-digests.timer:用于向订阅者发送每日摘要。 -
mailman3-gatenews.timer:每小时轮询NNTP服务器以获取新闻 -
mailman3-notify.timer:用于每天向管理员发送待处理请求的通知。
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 可以导入基于 mailman < 3.0 的列表数据库(config.pck)。以 mailman 用户身份(例如使用 sudo 或 su )运行以下命令:
[mailman]$ mailman import21 LISTSPEC PICKLE_FILE
这里,LISTSPEC 表示要导入的列表的全称(例如 list@example.com),PICKLE_FILE 表示列表的 config.pck 文件路径。
Mailman 公开了REST API,可使用基于 python-mailmanclient包 的自定义工具进行连接。
- Mailman 文档 - 上游文档
- Mailmanclient 文档 - 上游文档
- 连接到 Mailman - 关于mailman3-hyperkitty包的上游文档
- Mailman Suite 文档 - 整个 Mailman 套件(Mailman、Hyperkitty 和 Postorius)的(高级)上游文档