As I said in my previous post (please review the first part of it to see all the picture), after I made a succesfull mailman3 installation in one server with 2 mailman2 lists, I did it again with a jailed server with 17 mailman2 lists.
The servers: mercurio.mydomain.es (local IP 10.0.1.2) and
www.seconddomain.es as its jailed host (local IP 10.0.1.51) with 17 mailman lists.
The scope:
postfix config files in /usr/local/etc/postix (I attach main.cf as postfix-main.conf with all comment lines stripped)
postfix virtual users in /usr/local/etc/postfix/virtusertable
mailman3 services in /usr/local/mailman3
/usr/local/bin/python3.7 has a ln -s to /usr/local/bin/python3 (I had python linked to the 2.7 version yet)
In the jailed server (
www.seconddomain.es)
- portsnap fetch update
- install /usr/ports/mail/postfix
- followed the changing MTA from sendmail (only submit) to postfix guide
https://www.freebsd.org/doc/handbook/mail-changingmta.html
- created user for sasl2 authentication in /usr/local/etc/postfix/sasl_passwd and postmap it
[mercurio.mydomain.es]:587 mailoutuser: passoutuser
(there is no space after the colon, but this wysiwyg translate as a
, so I put one here)
(you have to create the user in the main server with "saslpasswd2 -c" )
- installed /usr/ports/devel/py-pip with FLAVOR=py37
- did a "ln -s /usr/local/bin/py37-pip to /usr/local/bin/pip" in order to clarity and follow guides
- pip install mailman
- installed /usr/ports/textproc/sassc and did an "ln -s /usr/local/bin/sassc /usr/bin/sassc" for django to find it (important)
- pip install mailmanclient
- created user mailman3 with the same gid and uid as mailman (1113:1113 in my system) and with /usr/local/mailman3 as home .
- mkdir /usr/local/mailman3 & chown mailman3:mailman /usr/local/mailman3
- install /usr/ports/devel/git
- cd /usr/local
- git clone
https://gitlab.com/mailman/mailman-suite.git
That clones mailman-suite and bring us some files to get config
- cd mailman-suite/mailman-suite_project
- su -m mailman3 -c " cp manage.py, urls.py and wsgi.py /usr/local/mailman3"
(you can now delete /usr/local/mailman-suite as is no longer needed)
I attach the mailman.conf file that would be /usr/local/mailman3/var/etc/mailman.cfg
[[[Post edition 12/27/20:
I've found that I missed to define one important thing in mailman.cfg
The site owner as it is the "from" address which sends you the unsuscribe notifications, etc.
You can see all the config possibilities in
https://docs.mailman3.org/projects/mailman/en/latest/src/mailman/config/docs/config.html
I've added these lines in the top of my mailman.cfg file
###########
[mailman]
site_owner:
webmaster@seconddomain.es
default_language: es
###########
(the second line, obviously, is not necessary for your config)
]]]
- installed /usr/ports/databases/py-pymysql as I want that mailman uses mysql database (and let Django with Sqlite3)
- Created a "mailman" database in mysql and granted permissions for IP, localhost and host "
www.seconddomain.es" accessing with "mysql -p -u root" and executing (I just put here the last grant)
"GRANT all privileges on mailman.* to 'mailman3'@'
www.seconddomain.es' IDENTIFIED BY 'databasepass' WITH GRANT OPTION;"
- installed
pip install postorius
pip install hyperkitty
pip install mailman-hyperkitty
pip install whoosh
"python3 -m django --version" shows 3.0.11 (that's it)
- installed /usr/ports/databases/py-sqlite3
I attached the settings.py.conf needed that would be /usr/local/mailman3/settings.py for Django
(Obtained and modified from the previous git run)
su -m mailman3 -c "mkdir /usr/local/mailman3/logs"
su -m mailman3 -c "touch /usr/local/mailman3/logs/mailmansuite.log"
Last thing:
As I installed postfix in /usr/local, mailman cannot find the postmap command to hash de virtual tables, then I did (using bash)
for fic in `ls /usr/local/sbin/post*`; do ln -s $fic /usr/sbin/`basename $fic`; done
There we go: (REMEMBER ALWAYS DO THINGS AS MAILMAN3 USER)
- cd /usr/local/mailman3
- su -m mailman3 -c "python3 manage.py migrate"
(This creates all the things needed)
- su -m mailman3 -c "python3 manage.py collectstatic"
- su -m mailman3 -c "python3 manage.py createsuperuser"
(the admin: in my example is
myuser@mydomain.es)
**** at this point you have all the django settings made. Before doing the apache24 part I have to say a couple of things:
In the virtualenv install guide stated you can start an instance of server with a
"python3 manage.py runserver". That's good to test the settings... but can confuse you because it's not needed at all if you have a "real server" like apache or nginx serving http. At least it have me missleaded for many days.
The hyperkitty config base path: it took me much frustrating time of confusion as in the guides it stated just as "
http://localhost/hyperkitty"... and it not archives any mail at all untill I understand that it have to be as it shows in my config file (well, I changed the access for "mailman3" but it would be preferable if it was noted as, say, "
http://localhost/hyperkitty/hiperkitty"
****
For the apache24 part I decided to use the mod-wsgi (and uswgi binary).
- pip install mod-wsgi
(with "mod_wsgi-express module-config" it shows the conf needed.)
- pip install uwsgi
- Included these lines in the "loadmodule" part of /usr/local/etc/apache24/httpd.conf
#####
LoadModule wsgi_module "/usr/local/lib/python3.7/site-packages/mod_wsgi/server/mod_wsgi-py37.so"
WSGIPythonHome "/usr/local"
WSGIDaemonProcess hyperkitty threads=25 python-path=/usr/local/mailman3 user=mailman3 group=mailman
WSGIProcessGroup hyperkitty
#####
- Included this line in the correct places of my /usr/local/etc/apache24/extra/httpd-vhosts.conf (in the listen 80 and 443 servers)
Include "/usr/local/mailman3/apache24.uwsgi.conf"
(I attach my apache24.uwsgi.conf. Remember I have a Drupal site enabled here)
- service apache24 restart
- initiated the uwsgi with a
/usr/local/bin/uwsgi --ini /usr/local/mailman3/uwsgi.ini &
(beware the "&" backgrounding it)
As I can only attach 5 files I put it here
####### start of /usr/local/mailman3/uwsgi.ini
# uwsgi.ini
#
[uwsgi]
# Port on which uwsgi will be listening.
http-socket = 0.0.0.0:8000
# Move to the directory wher the django files are.
chdir = /usr/local/mailman3/
# Use the wsgi file provided with the django project.
wsgi-file = wsgi.py
# Setup default number of processes and threads per process.
master = true
process = 2
threads = 2
# Drop privielges and don't run as root.
uid = www
gid = www
# Setup the django_q related worker processes.
attach-daemon = ./manage.py qcluster
# Setup the request log.
req-logger = file://usr/local/mailman3/logs/uwsgi.log
# Log cron seperately.
logger = cron file://usr/local/mailman3/logs/uwsgi-cron.log
log-route = cron uwsgi-cron
# Log qcluster commands seperately.
logger = qcluster file://usr/local/mailman3/logs/uwsgi-qcluster.log
log-route = qcluster uwsgi-daemons
# Last log and it logs the rest of the stuff.
logger = file://usr/local/mailman3/logs/uwsgi-error.log
####### end of /usr/local/mailman3/uwsgi.ini
And thats all about mailman 3 configuration. You can start all with two commands
/usr/bin/su -m mailman3 -c "/usr/local/bin/mailman -C /usr/local/mailman3/var/etc/mailman.cfg start"
/usr/local/bin/uwsgi --ini /usr/local/mailman3/uwsgi.ini &
I created a mailman3.sh to start, stop and restart all when needed if someone wants it I'll attach it in other post.
Then you have to create the lists in postorious and migrate following the guide in
https://docs.mailman3.org/en/latest/migration.html
It works very very well (I migrated all the lists without any problem)
One thing I did is declare as domain "seconddomain.es" and as alias "
www.seconddomain.es" in the postorious config for adding domains.
You do remember that
www.seconddomain.es was jailed, isn't it? And the MX server in DNSs for seconddomain.es is mercurio.mydomain.es. That implies that we need to "resend" the mail for the lists from mercurio.mydomain.es to
www.seconddomain.es (as with mailman2 was mercurio the server that manages mailman2 lists).
To do that I use a virtual user table in postfix I named "virtusertable" (like in sendmail). That's why I append mail.seconddomain.es in muy destinations in postfix.
Say you have the list one_list@ seconddomain.es
I created in /usr/local/etc/postfix/virtusertable the following lines:
# Virtual mappings for the @seconddomain.es domain.
one_list@seconddomain.es one_list@www.seconddomain.es
one_list-bounces@seconddomain.es one_list-bounces@www.seconddomain.es
....
one_list@mail.seconddomain.es one_list@www.seconddomain.es
one_list-bounces@mail.seconddomain.es one_list-bounces@www.seconddomain.es
....
I did not copied here all the lineas needed, but you can get them easily doing a
"cat /usr/local/mailman3/var/data/postfix_vmap >> /usr/local/etc/postfix/virtusertable"
and adding the "mail.seconddomain.es" entries for each list.
And don't forget to postmap /usr/local/etc/postfix/virtusertable (and service postfix reload after that)
That sends all email for lists to the correct addresses
To manage that in mercurio.mydomain.es I configured the local-unbound process, and, for sendmail, configured /etc/mail/mailertable and /etc/mail/virtusertable.
in mercurio:
/var/unbound/unbound.conf:
#
www.seconddomain.es local zone
private-domain: "
www.seconddomain.es"
local-zone: "
www.seconddomain.es." static
local-data: "
www.seconddomain.es. IN A 10.0.1.51"
local-data: "mail.seconddomain.es. IN A 10.0.1.51"
local-data: "
www.seconddomain.es. IN MX 10 mail.seconddomain.es."
local-data-ptr: "10.0.1.51
www.seconddomain.es."
/etc/mail/mailertable:
www.seconddomain.es smtp:[mail.seconddomain.es]
/etc/mail/virtusertable:
one_list@seconddomain.es one_list@mail.seconddomain.es
one_list-bounces@seconddomain.es one_list-bounces@mail.seconddomain.es
... (rest of the hooks for the list)
The reason to do it this way (using a "fake" mail.seconddomain.es server) is because I didn't achieve to resend emails in other way as mailertable did not work.
And that's all...