mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-17 05:41:25 +02:00
275 lines
8.4 KiB
Plaintext
275 lines
8.4 KiB
Plaintext
:q
|
|
Installation
|
|
============
|
|
|
|
Requirements
|
|
------------
|
|
|
|
- Python version 2.5+
|
|
- Django version 1.0+ (http://docs.djangoproject.com/en/dev/intro/install/#intro-install)
|
|
|
|
How to install
|
|
--------------
|
|
|
|
Download Mailng's tarball and extract it::
|
|
|
|
tar xzf mailng-<version>.tar.gz
|
|
mv mailng-<version> mailng
|
|
|
|
Enter the mailng directory, create a settings.py file (you can use
|
|
settings-sample.py as a model). Specify database relative informations. You
|
|
must choose between mysql and postgresql, other types are not supported by
|
|
major email projects like postfix or dovecot.
|
|
|
|
Initialise the database by running the following command::
|
|
|
|
python manage.py syncdb
|
|
|
|
Create the super admin account (just follow the procedure).
|
|
|
|
Run the initialisation script. It will insert needed data into the database :
|
|
|
|
export PYTHONPATH=$PWD/..
|
|
DJANGO_SETTINGS_MODULE=mailng.settings ./scripts/populate.py
|
|
|
|
How to upgrade
|
|
--------------
|
|
|
|
0.5 -> 0.6 : No modifications have been made to the core SQL schema so you
|
|
just have to decompress the new tarball at the same location than your
|
|
current installation. Once done, go to MailNG repository and run::
|
|
|
|
python manage.py syncdb
|
|
|
|
You must also modify 'settings.py' in order to activate new components.
|
|
|
|
Host configuration
|
|
------------------
|
|
|
|
Before testing Mailng, you must create a group and a user that will be
|
|
used to store mails on the host filesystem. There is only one
|
|
group/user needed because we are in a virtual hosting configuration
|
|
(ie. users with non-UNIX accounts).
|
|
|
|
For example, create a vmail group::
|
|
|
|
groupadd vmail
|
|
|
|
Then create a vmail user::
|
|
|
|
useradd -g vmail -d /var/vmail -m vmail
|
|
|
|
At last, the system user used to run mailng will need permissions to
|
|
manipulate directories in vmail's homedir. To do that, edit your /etc/sudoers
|
|
file and add the following inside::
|
|
|
|
www-data ALL=(vmail) NOPASSWD: ALL
|
|
|
|
Testing installation
|
|
--------------------
|
|
|
|
As a typical Django application, Mailng can be tested using a simple web
|
|
server. Just run this command to start it::
|
|
|
|
python manage.py runserver
|
|
|
|
You will be able to play with mailng by looking at
|
|
http://<youraddress>:8000/mailng/admin/.
|
|
|
|
Tips to link Mailng with postfix
|
|
--------------------------------
|
|
|
|
First, define following maps on your server (this should work with
|
|
Postfix versions >= 2.2)::
|
|
|
|
# /etc/postfix/sql-domains.cf
|
|
user = <user>
|
|
password = <password>
|
|
dbname = <database>
|
|
hosts = 127.0.0.1
|
|
query = SELECT name FROM admin_domain WHERE name='%s' AND enabled='1'
|
|
|
|
# /etc/postfix/sql-mailboxes.cf
|
|
user = <user>
|
|
password = <password>
|
|
dbname = <database>
|
|
hosts = 127.0.0.1
|
|
query = SELECT path FROM admin_mailbox WHERE full_address = '%s'
|
|
|
|
# /etc/postfix/sql-aliases.cf
|
|
user = <user>
|
|
password = <password>
|
|
dbname = <database>
|
|
hosts = 127.0.0.1
|
|
query = SELECT t2.full_address FROM admin_alias AS t1, admin_mailbox AS t2 WHERE t1.full_address='%s' AND t1.mbox_id=t2.id AND t1.enabled='1'
|
|
|
|
Then, use the following configuration in your /etc/postfix/main.cf file
|
|
(this is one possible configuration)::
|
|
|
|
# Stuff before
|
|
mailbox_transport = virtual
|
|
home_mailbox = .maildir/
|
|
maildrop_destination_recipient_limit = 1
|
|
virtual_minimum_uid = <vmail user id>
|
|
virtual_gid_maps = static:<vmail group id>
|
|
virtual_uid_maps = static:<vmail user id>
|
|
virtual_mailbox_base = /var/vmail
|
|
|
|
relay_domains =
|
|
virtual_mailbox_domains = mysql:/etc/postfix/sql-domains.cf
|
|
virtual_mailbox_maps = mysql:/etc/postfix/sql-mailboxes.cf
|
|
virtual_alias_maps = mysql:/etc/postfix/sql-aliases.cf
|
|
# Stuff after
|
|
|
|
NB: Mailng supports both maildir and mbox formats. You can specify
|
|
which format to use by modifying the MAILBOX_TYPE variable located
|
|
inside 'settings.py'.
|
|
|
|
Tips to activate auto-reply messages in Postifx
|
|
-----------------------------------------------
|
|
|
|
Since version 0.6, mail users can define an auto-reply message with MailNG.
|
|
To make Postfix understand this feature, you need to update your configuration
|
|
files as follow::
|
|
|
|
# /etc/postfix/main.cf
|
|
transport_maps = mysql:/etc/postfix/maps/sql-transport.cf
|
|
virtual_alias_maps = mysql:/etc/postfix/maps/sql-aliases.cf
|
|
mysql:/etc/postfix/maps/sql-autoreplies.cf
|
|
|
|
# /etc/postfix/master.cf
|
|
autoreply unix - n n - - pipe
|
|
flags= user=nobody argv=<path_to_mailng>/scripts/autoreply $sender $mailbox
|
|
|
|
Then, create new map files with the following content::
|
|
|
|
# /etc/postfix/maps/sql-transport.cf
|
|
user = <user>
|
|
password = <password>
|
|
dbname = <database>
|
|
hosts = 127.0.0.1
|
|
query = SELECT method FROM postfix_autoreply_transport WHERE domain='%s'
|
|
|
|
# /etc/postfix/maps/sql-autoreplies.cf
|
|
user = <user>
|
|
password = <password>
|
|
dbname = <database>
|
|
hosts = 127.0.0.1
|
|
query = SELECT full_address, autoreply_address FROM postfix_autoreply_alias WHERE full_address='%s'
|
|
|
|
NB: auto-reply messages are just sent one time per sender for a
|
|
pre-defined time period. By default, this period is equal to 1 day
|
|
(86400s), you can adjust this value by modifying the AUTOREPLY_TIMEOUT
|
|
variable located inside 'settings.py'.
|
|
|
|
NB: Be sure that both 'autoreply' and 'autoreply.py' scripts (located
|
|
inside the 'scripts' directory) have good permissions (ie. 0755).
|
|
|
|
Tips to link Mailng with dovecot
|
|
--------------------------------
|
|
|
|
If you are using 'maildir' format to store mailboxes, add the
|
|
following line inside your main Dovecot config file
|
|
(/etc/dovecot/dovecot.conf)::
|
|
|
|
mail_location = maildir:<path_to_mailboxes>/%d/%n/.maildir
|
|
|
|
If you are using 'mbox' format, put the following::
|
|
|
|
mail_location = mbox:<path_to_mailboxes>/%d/%n/:INBOX=<path_to_mailboxes>/%d/%n/Inbox
|
|
|
|
To make the authentication work, edit 'dovecot.conf' and add the
|
|
following inside::
|
|
|
|
auth default {
|
|
# ... stuff before
|
|
|
|
passdb sql {
|
|
# Path for SQL configuration file, see /etc/dovecot/dovecot-sql.conf for
|
|
# example
|
|
args = /etc/dovecot/dovecot-sql.conf
|
|
}
|
|
|
|
userdb sql {
|
|
# Path for SQL configuration file
|
|
args = /etc/dovecot/dovecot-sql.conf
|
|
}
|
|
|
|
# ... stuff after
|
|
}
|
|
|
|
Be sure to activate only one backend (per type) inside your configuration
|
|
(comment other ones).
|
|
|
|
Then, edit your /etc/dovecot/dovecot-sql.conf and modify following lines::
|
|
|
|
driver = mysql
|
|
connect = host=<mysqld socket> dbname=<database> user=<user> password=<password>
|
|
default_pass_scheme = PLAIN-MD5
|
|
password_query = SELECT full_address AS user, password FROM admin_mailbox WHERE full_address = '%u'
|
|
user_query = SELECT path AS home, uid, gid FROM admin_mailbox WHERE full_address = '%u'
|
|
|
|
Enable quotas with Dovecot
|
|
--------------------------
|
|
|
|
Put the following lines inside your dovecot.conf file::
|
|
|
|
protocol imap {
|
|
mail_plugins = quota quota_imap
|
|
}
|
|
|
|
Before continuing, you need to know which quota backend must be user
|
|
(function of mailboxes format)::
|
|
* 'mbox' : backend=dirsize,
|
|
* 'maildir' : backend=maildir.
|
|
|
|
If you use version prior to 1.1, add also the following configuration::
|
|
|
|
plugin {
|
|
# 10 MB default quota limit
|
|
quota = <backend>:storage=10240
|
|
}
|
|
|
|
Then modify the above user_query inside dovecot-sql.conf file like
|
|
that to activate per user quotas::
|
|
|
|
user_query = SELECT path AS home, uid, gid, concat('<backend>:storage=', quota / 1024) AS quota FROM admin_mailbox WHERE full_address = '%u'
|
|
|
|
For version >= 1.1, put the following configuration inside dovecot.conf file::
|
|
|
|
plugin {
|
|
# Default 10M storage limit with an extra 5M limit when saving to Trash.
|
|
quota = <backend>:User quota
|
|
quota_rule = *:storage=10M
|
|
quota_rule2 = Trash:storage=5M
|
|
}
|
|
|
|
Then modify the above user_query inside dovecot-sql.conf to activate
|
|
user quotas::
|
|
|
|
user_query = SELECT path AS home, uid, gid, concat('*:storage=', quota, 'M') AS quota_rule FROM admin_mailbox WHERE full_address = '%u'
|
|
|
|
Tips to server Mailng behind Apache2
|
|
------------------------------------
|
|
|
|
First, be sure to have apache2 and mod_python installed on your
|
|
server.
|
|
|
|
Create a new virtualhost in your Apache configuration and put the
|
|
following inside::
|
|
|
|
<VirtualHost *:80>
|
|
<Location "/">
|
|
SetHandler mod_python
|
|
PythonHandler django.core.handlers.modpython
|
|
PythonPath "['<path to directory that contains mailng dir>'] + sys.path"
|
|
SetEnv DJANGO_SETTINGS_MODULE mailng.settings
|
|
</Location>
|
|
Alias "/static" "<path to mailng dir>/static"
|
|
<Location "/static/">
|
|
SetHandler None
|
|
</Location>
|
|
</VirtualHost>
|
|
|
|
This is one possible configuration. Note that you will certainly need more
|
|
configuration in order to launch Apache. |