CentOS8でサーバー構築 - 9.mailmanのインストールと設定(Postfix)

メールホストkowloonet.net
URLホストadmin.kowloonet.net
URLhttps://admin.kowloonet.net/mailman/admin/
で設定します。

mailmanのインストール

mailmanインストール
# dnf -y install mailman

mailmanの設定

mm_cfg.pyの編集
# vi /etc/mailman/mm_cfg.py
DEFAULT_URL_HOST   = 'kowloonet.net'
DEFAULT_EMAIL_HOST = 'kowloonet.net'
Defaults.pyの編集
# vi /usr/lib/mailman/Mailman/Defaults.py
# Mailman needs to know about (at least) two fully-qualified domain names
# (fqdn); 1) the hostname used in your urls, and 2) the hostname used in email
# addresses for your domain.  For example, if people visit your Mailman system
# with "http://www.dom.ain/mailman" then your url fqdn is "www.dom.ain", and
# if people send mail to your system via "yourlist@dom.ain" then your email
# fqdn is "dom.ain".  DEFAULT_URL_HOST controls the former, and
# DEFAULT_EMAIL_HOST controls the latter.  Mailman also needs to know how to
# map from one to the other (this is especially important if you're running
# with virtual domains).  You use "add_virtualhost(urlfqdn, emailfqdn)" to add
# new mappings.
#
# If you don't need to change DEFAULT_EMAIL_HOST and DEFAULT_URL_HOST in your
# mm_cfg.py, then you're done; the default mapping is added automatically.  If
# however you change either variable in your mm_cfg.py, then be sure to also
# include the following:
#
#     add_virtualhost(DEFAULT_URL_HOST, DEFAULT_EMAIL_HOST)
#
# because otherwise the default mappings won't be correct.
DEFAULT_EMAIL_HOST = 'kowloonet.net'
DEFAULT_URL_HOST = 'admin.kowloonet.net'
DEFAULT_URL_PATTERN = 'https://%s/mailman/'
# MTA -- but then also see POSTFIX_STYLE_VIRTUAL_DOMAINS.
MTA = 'Postfix'
・
・
# The default language for this server.  Whenever we can't figure out the list
# context or user context, we'll fall back to using this language.  See
# LC_DESCRIPTIONS below for legal values.
DEFAULT_SERVER_LANGUAGE = 'ja'
・
・
# Set this variable to Yes to allow list owners to delete their own mailing
# lists.  You may not want to give them this power, in which case, setting
# this variable to No instead requires list removal to be done by the site
# administrator, via the command line script bin/rmlist.
OWNERS_CAN_DELETE_THEIR_OWN_LISTS = Yes
・
・
# These format strings will be expanded w.r.t. the dictionary for the
# mailing list instance.
DEFAULT_SUBJECT_PREFIX  = "[%(real_name)s: %%d] "

# What should happen to non-member posts which are do not match explicit
# non-member actions?
# 0 = Accept
# 1 = Hold
# 2 = Reject
# 3 = Discard
DEFAULT_GENERIC_NONMEMBER_ACTION = 0
・
・
# Mailman can be configured to "munge" Reply-To: headers for any passing
# messages.  One the one hand, there are a lot of good reasons not to munge
# Reply-To: but on the other, people really seem to want this feature.  See
# the help for reply_goes_to_list in the web UI for links discussing the
# issue.
# 0 - Reply-To: not munged
# 1 - Reply-To: set back to the list
# 2 - Reply-To: set to an explicit value (reply_to_address)
DEFAULT_REPLY_GOES_TO_LIST = 0
・
・
# SUBSCRIBE POLICY
# 0 - open list (only when ALLOW_OPEN_SUBSCRIBE is set to 1) **
# 1 - confirmation required for subscribes
# 2 - admin approval required for subscribes
# 3 - both confirmation and admin approval required
#
# ** please do not choose option 0 if you are not allowing open
# subscribes (next variable)
DEFAULT_SUBSCRIBE_POLICY = 2
・
・
 Are archives on or off by default?
DEFAULT_ARCHIVE = Off
・
・
# Will list be available in digested form?
DEFAULT_DIGESTABLE = No
エイリアス作成
# /usr/lib/mailman/bin/genaliases
管理者パスワード作成
# /usr/lib/mailman/bin/mmsitepass
管理用メーリングリスト作成
# /usr/lib/mailman/bin/newlist mailman
Enter the email of the person running the list: example@example.com
Initial mailman password:
Hit enter to notify mailman owner...
パーミッション修正
# /usr/lib/mailman/bin/check_perms -f
/etc/mailman/aliases bad group (has: root, expected mailman) (fixing)
/etc/mailman/adm.pw bad group (has: root, expected mailman) (fixing)
/usr/lib/mailman/Mailman/Defaults.pyc bad group (has: root, expected mailman) (fixing)
/usr/lib/mailman/Mailman/mm_cfg.pyc bad group (has: root, expected mailman) (fixing)
/var/log/mailman/error bad group (has: root, expected mailman) (fixing)
Problems found: 5
Re-run as mailman (or root) with -f flag to fix
# chown apache /etc/mailman/aliases
# chmod 664 /etc/mailman/aliases*
# chmod 2775 /etc/mailman
パーミッション修正確認
# /usr/lib/mailman/bin/check_perms
No problems found
mailman起動と自動起動設定
# systemctl enable --now mailman
# /usr/lib/mailman/bin/newlist mailman
Enter the email of the person running the list: example@example.com
Initial mailman password:
postalias: fatal: open /etc/mailman/aliases.db: Permission denied
Traceback (most recent call last):
  File "/usr/lib/mailman/bin/newlist", line 274, in 
    main()
  File "/usr/lib/mailman/bin/newlist", line 240, in main
    sys.modules[modname].create(mlist)
  File "/usr/lib/mailman/Mailman/MTA/Postfix.py", line 342, in create
    _update_maps()
  File "/usr/lib/mailman/Mailman/MTA/Postfix.py", line 78, in _update_maps
    raise RuntimeError, msg % (acmd, status, errstr)
RuntimeError: command failed: /usr/sbin/postalias /etc/mailman/aliases (status: 1, Operation not permitted)
などとエラーが出た場合は。
# /usr/lib/mailman/bin/check_perms -f
を実行してパーミッションを修正する。
管理者パスワードの変更
/usr/lib/mailman/bin/mmsitepass
メーリングリストの削除
# /usr/lib/mailman/bin/rmlist メーリングリスト名

Postfixの設定

mailman起動とサービス追加
# vi /etc/postfix/main.cf
#alias_maps = dbm:/etc/aliases
#alias_maps = hash:/etc/aliases
#alias_maps = hash:/etc/aliases, nis:mail.aliases
#alias_maps = netinfo:/aliases
alias_maps = hash:/etc/aliases, hash:/etc/mailman/aliases
・
・
#alias_database = dbm:/etc/aliases
#alias_database = dbm:/etc/mail/aliases
#alias_database = hash:/etc/aliases
#alias_database = hash:/etc/aliases, hash:/opt/majordomo/aliases
alias_database = hash:/etc/aliases, hash:/etc/mailman/aliases
postfix再起動
 # systemctl restart postfix

Apacheの設定

mailman.confや他の .confを状況に応じて修正後Apache再起動
mailman.conf
# cd /etc/httpd/conf.d/
# cp mailman.conf mailman.conf.org
# vi mailman.conf
Apache再起動
# httpd -t
Syntax OK
# systemctl restart httpd

ブラウザでアクセス

https://ホスト名/mailman/admin/
にアクセス。