2017年10月10日火曜日

FreeBSD 11にmailmanをインストールする

FreeBSD 11にmailmanをインストールしたので、その経過を以下にまとめます。
$ pkg install apache24

$ pkg install ja-mailman
apache24が動作するように最低限の設定をしておきます。そしてmailmanの設定です。

まず
/usr/local/mailman/Mailman/cfg_mm.py
に以下を追加します。
SMTPHOST = 'mail.example.com'
DEFAULT_URL_HOST = 'mail.example.com'
DEFAULT_EMAIL_HOST = 'mail.example.com'

add_virtualhost(DEFAULT_URL_HOST, DEFAULT_EMAIL_HOST)
このほか、必要に応じて、以下のような設定を追加します。設定できるパラメータは
/usr/local/mailman/Mailman/Defaults.py
記述があります。これは、メーリングリストを作るたびにいつも設定をしていたパラメータで、めんどくさいのでデフォルトの値を変更することにしました。
# What shold 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

# Are archives on or off by default?
DEFAULT_ARCHIVE = No

# Are archives public or private by default?
# 0=public, 1=private
DEFAULT_ARCHIVE_PRIVATE = 1

# Should a list, by default be advertised?  What is the default maximum number
# of explicit recipients allowed?  What is the default maximum message size
# allowed?
DEFAULT_LIST_ADVERTISED = No
DEFAULT_MAX_NUM_RECIPIENTS = 20
DEFAULT_MAX_MESSAGE_SIZE = 100000           # KB

# Private_roster == 0: anyone can see, 1: members only, 2: admin only.
DEFAULT_PRIVATE_ROSTER = 2

# These format strings will be expanded w.r.t. the dictionary for the
# mailing list instance.
# DEFAULT_SUBJECT_PREFIX  = "[%(real_name)s] "
DEFAULT_SUBJECT_PREFIX = "[%(real_name)s %%d]" # for numbering
DEFAULT_MSG_HEADER = ""
DEFAULT_MSG_FOOTER = ""

# See "Bitfield for user options" below; make this a sum of those options, to
# make all new members of lists start with those options flagged.  We assume
# by default that people don't want to receive two copies of posts.  Note
# however that the member moderation flag's initial value is controlled by the
# list's config variable default_member_moderation.
DEFAULT_NEW_MEMBER_OPTIONS = 0

# # Bitfield for user options.  See DEFAULT_NEW_MEMBER_OPTIONS above to set
# defaults for all new lists.
# Digests             = 0 # handled by other mechanism, doesn't need a flag.
# DisableDelivery     = 1 # Obsolete; use set/getDeliveryStatus()
# DontReceiveOwnPosts = 2 # Non-digesters only
# AcknowledgePosts    = 4
# DisableMime         = 8 # Digesters only
# ConcealSubscription = 16
# SuppressPasswordReminder = 32
# ReceiveNonmatchingTopics = 64
# Moderate = 128
# DontReceiveDuplicates = 256

# 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 = 1

# 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
次にWeb UIでアイコンが欠損しているのでこれを補います。「FreeBSD powerd logo」を検索して
/usr/local/mailman/icons/powerlogo.gif
に置きます。この後、Web インターフェース用のパスワードを設定します。
# LANC=C /usr/local/mailman/bin/mmsitepass
パスワード: XXXXX
#
そしてmailman管理用メーリングリストを作ります。
# /usr/local/mailman/bin/newlist mailman
パスワード: XXXX
管理者: system@mail.example.com
mailman用の alias ファイルを作成します。
# /usr/local/mailman/bin/genaliases
(/usr/local/mailman/data/aliasとalias.dbが作成される)
mailman用のファイル・ディレクトリ権限を設定します。 
# /usr/local/mailman/bin/check_perms -f -v
そして次は、apache24の設定です。
$ cd /usr/local/etc/apache24/Includes/
$ vi mailman.conf 


ScriptAlias     /mailman        "/usr/local/mailman/cgi-bin"
Alias           /icons          "/usr/local/mailman/icons"

LoadModule cgid_module libexec/apache24/mod_cgid.so

<Directory "/usr/local/mailman">
        Options +ExecCGI 
        AllowOverride None
        Require all granted
</Directory>

$
cgid.soと+ExecCGIはCGIを有効にするための、 そして「Required all granted」はこのディレクトリへのアクセスを可能にするためのものです。