-
Notifications
You must be signed in to change notification settings - Fork 41
Install and Configure Mailman3 Suite for GraphSpace (Ubuntu 16.04, PostgreSQL, Apache2, Postfix)
Requirements: Python v2.7, Python v3.5+ (This document used Python v3.5), Apache2, Postfix.
- Get all of the necessary source code:
git clone https://gitlab.com/thelinuxguy/mailman-suite
cd mailman-suite
git clone https://gitlab.com/mailman/mailman.git
git clone https://gitlab.com/mailman/mailman-hyperkitty.git
-
Creat a postgres database for Mailman3-suite:
sudo -u <database user name> createdb -O postgres <database name>
. Example:sudo -u postgres createdb -O postgres mailman
. -
Make virtual environments:
virtualenv -p python2 venv-2.7
virtualenv -p python3.5 venv-3.5
- Install and configure mailman core:
source venv-2.7/bin/activate
cd mailman
../venv-3.5/bin/python setup.py develop
sudo vim var/etc/mailman.cfg #the path of mailman.cfg can be found from the output of command `../venv-3.5/bin/mailman info`
Add following to mailman.cfg:
[database]
class: mailman.database.postgresql.PostgreSQLDatabase
url: postgres://<database user name>:<password>@localhost/<database name>
- Install all dependencies for Mailman3-suite:
../venv-3.5/bin/pip install psycopg2-binary==2.7.5
pip install --update pip
pip install -U setuptools
pip install django==1.10
pip install django-haystack==2.5.1
pip install django-allauth==0.32.0
pip install postorius==1.1.2
pip install hyperkitty==1.1.4
pip install mailmanclient==3.1.1
pip install django-mailman3==1.1.0
pip install whoosh==2.7.4
pip install psycopg2-binary==2.7.5
sudo apt-get install ruby-sass
cd ..
- Edit the following in
sudo vim mailman_suite/settings.py
:
ALLOWED_HOSTS = ['localhost',
'email.graphspace.org', #The URL of mailman_suite django project
'18.188.234.43'] #The actual public ip address of mailman_suite django project
# uncomment hyperkitty and postorius to enable them
INSTALLED_APPS = (
...
'postorius',
'hyperkitty',
...
)
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': '<database name>',
'USER': '<database user name>',
'PASSWORD': '<password (if any)>',
'HOST': 'localhost',
}
}
# Add this part to settings.py
COMPRESS_ENABLED = True
COMPRESS_OFFLINE = True
COMPRESS_PRECOMPILERS = (
('text/x-scss', 'sass {infile} {outfile}'),
('text/x-sass', 'sass {infile} {outfile}'),
)
MAILMAN_ARCHIVER_KEY = 'SecretArchiverAPIKey'
MAILMAN_ARCHIVER_FROM = ('18.188.234.43', '::1') #The actual public ip addresses of mailman_suite django project
# Add this part to settings.py
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'localhost'
EMAIL_PORT = 25
- Install mailman_suite:
python manage.py migrate
python manage.py collectstatic
python manage.py createsuperuser
django-admin compress --pythonpath mailman_suite --settings settings
- Install and setup mailman-hyperkitty:
cd mailman-hyperkitty
../venv-3.5/bin/python setup.py develop
sudo apt-get install redis-server
Edit following in sudo vim mailman-hyperkitty.cfg
:
#mailman-hyperkitty.cfg
[general]
base_url: http://email.graphspace.org/hyperkitty/ #Replace email.graphspace.org with your URL of mailman_suite django project
api_key: SecretArchiverAPIKey
- Enable hyperkitty in mailman core:
cd .. #you are now in the mailman-suite directory
, add following tosudo vim mailman/var/etc/mailman.cfg
#mailman.cfg
[archiver.hyperkitty]
class: mailman_hyperkitty.Archiver
enable: yes
configuration: <absolute path to mailman-hyperkitty.cfg>
10 Start mailman core
cd mailman
../venv-3.5/bin/mailman start
cd ..
Now you can deactivate virtual environments and return to root.
- Confirue Postfix
Edit following in /etc/postfix/main.cf
, graphspace.org
in this file is your mail host.
myhostname = graphspace.org
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = myhostname, graphspace.org, email.graphspace.org, localhost.localdomain, localhost
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_command = /usr/bin/procmail
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = all
home_mailbox = Maildir/
virtual_alias_maps = hash:/etc/postfix/virtual
unknown_local_recipient_reject_code = 550
owner_request_special = no
transport_maps =
hash:/home/ubuntu/mailman-suite/mailman/var/data/postfix_lmtp
local_recipient_maps =
hash:/home/ubuntu/mailman-suite/mailman/var/data/postfix_lmtp
relay_domains = graphspace.org
Add aliases of email list to /etc/aliases
. For example, we create the email list [email protected]
. We need to add following to /etc/aliases
:
graphspace-users lmtp:[127.0.0.1]:8024
graphspace-users-bounces lmtp:[127.0.0.1]:8024
graphspace-users-confirm lmtp:[127.0.0.1]:8024
graphspace-users-join lmtp:[127.0.0.1]:8024
graphspace-users-leave lmtp:[127.0.0.1]:8024
graphspace-users-owner lmtp:[127.0.0.1]:8024
graphspace-users-request lmtp:[127.0.0.1]:8024
graphspace-users-subscribe lmtp:[127.0.0.1]:8024
graphspace-users-unsubscribe lmtp:[127.0.0.1]:8024
This has to be done manually for each new list that you create. Whenever you modify /etc/aliases
, you need to run
sudo newaliases
sudo service postfix restart
- Create file
mailman-suite.conf
in/etc/apache2/sites-enabled
, and add the following lines to it:
<VirtualHost *:80>
ServerAlias email.graphspace.org #The URL of mailman_suite django project
# please replace all below /home/ubuntu/mailman-suite with your path to mailman-suite.
WSGIDaemonProcess mailman-suite python-path=/home/ubuntu/mailman-suite:/home/ubuntu/mailman-suite/venv-2.7/lib/python2.7/site-packages
WSGIProcessGroup mailman-suite
WSGIScriptAlias / /home/ubuntu/mailman-suite/mailman_suite/wsgi.py process-group=mailman-suite
Alias /static /home/ubuntu/mailman-suite/public/static
<Directory /home/ubuntu/mailman-suite/public/static>
Require all granted
</Directory>
<Directory /home/ubuntu/mailman-suite/mailman_suite>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
<Directory /home/ubuntu/mailman-suite>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
</VirtualHost>
Restart the apache server: sudo service apache2 restart