• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

docs/H03-May-2022-1,9651,543

setup/H23-Jan-2022-804541

vexim/H03-May-2022-13,82211,608

.gitattributesH A D23-Jan-2022337 1411

.gitignoreH A D23-Jan-202227 21

LICENSEH A D23-Jan-20221.4 KiB2722

README.mdH A D23-Jan-202215.8 KiB245195

TODOH A D23-Jan-20223.4 KiB8478

README.md

1# Virtual Exim 2
2
3## WARNING: This code is probably unsafe
4
5As noted in [#272](https://github.com/vexim/vexim2/issues/272) there might be security issues in this code. It was written as a helpful utility in 2004 and has had minimal changes since then. Very little effort went in at the time to protect it against various security attacks. While we do eventually fix security issues we become aware of, we aren't bound by any SLAs, so fixes don't always happen quickly.
6
7Patches to fix security issues will be accepted as time permits, but the code (especially the admin panel) certainly needs an overhaul, and that will only happen if someone with enough time and motivation steps up. In fact, a potential replacement for our aged PHP admin panel already exists. Meet [veximpy](https://gitlab.com/runout/veximpy)!
8
9In short:
10- If you are considering VExim, we advise you to at least have a look at [other similar solutions](https://alternativeto.net/software/postfix-admin/) as well.
11- If you are already using VExim, please consider taking extra steps to secure it.
12- If you're interested in contributing a rewrite, or participating in one, let us know
13- And of course, pull requests with bugfixes are always welcome!
14
15## README AND INSTALL GUIDE
16
17Thanks for picking the Virtual Exim package, for your virtual mail hosting needs! :-)
18
19This document provides a basic guide on how to get Virtual Exim working on your system. In this guide, I assume that you have *a little* knowledge of both MySQL and Exim.
20
21Before we go into any details, I'd like to thanks Philip Hazel and the Exim developers for a fine product. I would also like to thanks the postmasters at various domains for letting me play havoc with their mail while I set this up :-) Finally, a special note of thanks to Dan Bernstein for his Qmail MTA. Dan, thank you for educating me how mail delivery really shouldn't be done, on the Internet.
22
23The Virtual Exim project currently lives on GitHub: https://github.com/vexim/vexim2
24And its mailing list/Google group is available at: https://groups.google.com/group/vexim
25
26## Installation steps for each component:
27
28##### NOTE FOR UPGRADING:
29If you are upgrading from a previous version of Virtual Exim, you'll find additional notes marked 'UPGRADING' in some sections. If and when you do, follow these notes.
30
31##### DISTRIBUTION-SPECIFIC NOTES:
32Some sections may contain distribution or OS-specific notes. You'll find them after an appropriate prefix, such as 'DEBIAN' or 'FREEBSD' where appropriate.
33
34## PARTS:
351. [Prerequisites](#prerequisites)
362. [System user](#system-user)
373. [Databases and authentication](#databases-and-authentication)
384. [Files and Apache](#files-and-apache)
395. [Mailman](#mailman)
406. [Exim configuration](#exim-configuration)
417. [Site Admin](#site-admin)
428. [Virtual Domains](#virtual-domains)
439. [Mail storage and Delivery](#mail-storage-and-delivery)
4410. [POP3 and IMAP daemons (separate to this software)](#pop3-and-imap-daemons)
45
46## Prerequisites:
47The following packages must be installed on your system, for Virtual Exim to work. If you don't have any of these packages already installed, please refer to the documentation provided with your operating system on how to install each package:
48* Exim v4 with MySQL or PostgreSQL support (tested on v4.1x/4.2x/4.7x)
49* MySQL (tested on v5.1.x) or PostgreSQL
50* Apache or other HTTP server (Tested with Apache v2.2.x and NginX)
51* PHP (tested on v5.3.x, v7.x and v8.x) with at least the following extensions:
52  * PDO
53  * pdo_mysql or pdo_pgsql
54  * imap
55  * gettext
56  * iconv
57  * filter
58
59The following packages provide optional functionality:
60* Mailman – to have mailing lists
61* ClamAV – for scanning e-mail for viruses
62* SpamAssassin – for scanning e-mail from spam
63
64VExim might work with older (or newer) versions of these packages, but you may have to perform some adaptation work to achieve that. In any case, you are welcome to file bugs and/or provide patches on GitHub.
65
66**DEBIAN:** The following command line installs all the packages mentioned above (last four are optional), if you're going with MySQL setup:
67```
68# apt-get install apache2 exim4-daemon-heavy mysql-server libapache2-mod-php php-mysql php-imap clamav-daemon clamav-freshclam spamassassin mailman
69```
70
71## System user:
72You should create a new user account to whom the virtual mailboxes will belong. Since you do not want anyone to be able to login using that account, you should also disable logging in for that user. Here are the command lines to do that. This manual assumes you want to have your virtual mailboxes in /var/vmail. If you want them elsewhere, adjust the commands. After the user and group are created, find their uid and gid using the last command and memorize these values:
73```
74# useradd -r -m -U -s /bin/false -d /var/vmail vexim
75# id vexim
76```
77**FREEBSD:** Instead of the commands above, you should probably use the following (change `90` to another value if this user or group id is already used on your system):
78```
79# pw groupadd vexim -g 90
80# pw useradd vexim -u 90 -g vexim -d /usr/local/mail -m -s /nonexistant
81```
82**DEBIAN:** Use the following command instead:
83```
84# adduser --system --home /var/vmail --disabled-password --disabled-login --group vexim
85```
86
87## Databases and authentication:
88
89### MySQL:
90This distribution contains a file "vexim2/setup/mysql.sql". This file provides the database schema used by vexim. You will have to import it into MySQL, like this:
91```
92# mysql -u root -D YOUR_DATABASE_NAME -p < vexim2/setup/mysql.sql
93```
94Where `YOUR_DATABASE_NAME` is the name of an empty database you have created for vexim. If you want the script to create the database for you and set up access to it, this is also doable: just open it in a text editor, and find a commented out block which begins with `-- CREATE DATABASE` near the top of the file. This block is documented just above it, so you may uncomment it, apply the changes you want and save the file. With the necessary changes made, you should run the following command line to initialize the database:
95```
96# mysql -u root -p < vexim2/setup/mysql.sql
97```
98A site admininistrator account is created with an autogenerated password required for your first login to Vexim.
99
100### PGSQL:
101The code has been tested by several users to work with Virtual Exim, and we try our best to make sure it always will. Unfortunately I don't have much PostgreSQL knowledge to support it fully. A database schema for it is included however, as setup/pgsql.sql to help you set up the database. Make sure to adjust it similarly as per MySQL instructions above.
102
103**UPGRADING:**
104If you are upgrading your installation, we have prepared MySQL migration scripts for you, which you will find under vexim2/setup/migrations/. Find out the version of Vexim that you have and apply the necessary scripts in a sequential manner, like this:
105```
106# mysql -u root -D YOUR_DATABASE_NAME -p < vexim2/setup/migrations/SCRIPT_FILENAME.sql
107```
108
109## Files and Apache:
110In this distribution is a directory called 'vexim'. You have two options:
111* Copy this directory into your current DocumentRoot for your domain, and optionally rename the directory.
112* Set up a new VirtualHost and point the DocumentRoot to the vexim directory.
113
114Both should work equally well.
115
116After copying the 'vexim' directory, you should find the 'variables.php.example', file in its subdirectory called 'config', copy that file to 'variables.php' and change the following values defined in it:
117* $sqlpass – to the vexim database user's password which you chose while editing 'mysql.sql' in the "Databases and authentication" step.
118* $uid, $gid and $mailroot to the values you have from the "System user" step.
119* $cryptscheme is set to "sha512", a more specific configuration or other crypt-schemes can be used.
120* $mailmanroot to the mailman URL
121
122Other, less interesting options are documented in the comments of that file. Feel free to explore them as well.
123
124## Mailman:
125Mailman needs to be installed if you want to use mailing lists. Edit the default configuration file (`/etc/mailman/mm_cfg.py`):
126```
127DEFAULT_URL_PATTERN = 'https://%s/mailman/'
128DEFAULT_SERVER_LANGUAGE = 'en'
129DEFAULT_EMAIL_HOST = 'mail.example.tld'
130DEFAULT_URL_HOST   = 'mail.example.tld'
131```
132Debian will already create a default configuration for your webserver that you can enable with `a2ensite mailman`. Create your master password: `mmsitepass MY_PASSWORD``. Restart mailman and apache.
133
134## Exim configuration:
135**NOTE:** the configuration files supplied here have been revised. You should use them carefully and report problems!
136
137An example Exim 'configure' file, has been included with this distribution as 'docs/configure'. Copy this to the location Exim expects its configuration file to be on your installation. You will also need to copy docs/vexim* to /usr/local/etc/exim/. The following lines are important and will have to be edited if you are using this configure, or copied to your own configure file:
138
139
140Edit these if your mailman is in a different location (in Debian: `/var/lib/mailman`):
141```
142MAILMAN_HOME=/usr/local/mailman
143MAILMAN_WRAP=MAILMAN_HOME/mail/mailman
144```
145These need to match the username and group under which exim runs (in Debian: `list`/`daemon`):
146```
147MAILMAN_USER=mailnull
148MAILMAN_GROUP=mail
149```
150Change this to the name of your server:
151```
152primary_hostname=mail.example.org
153```
154In general, it is required that your reverse DNS entry of your IP points to this hostname.
155
156If you are using MySQL, uncomment the following two lines:
157```
158#VIRTUAL_DOMAINS = SELECT DISTINCT CONCAT(domain, ' : ') FROM domains type = 'local'
159#RELAY_DOMAINS = SELECT DISTINCT CONCAT(domain, ' : ') FROM domains type = 'relay'
160```
161If you are using PGSQL, uncomment the following four lines:
162```
163#VIRTUAL_DOMAINS = SELECT DISTINCT domain || ' : ' FROM domains WHERE type = 'local'
164#RELAY_DOMAINS = SELECT DISTINCT domain || ' : ' FROM domains WHERE type = 'relay'
165```
166Depending on the database type you are using, you will need to uncomment the appropriate lines in the config, to enable lookups.
167
168These control which domains you accept mail for and deliver locally (local_domains), which domains you accept mail for and deliver remotely (relay_to_domains), which IP addresses are allowed to send mail to any domain (relay_from_hosts) and which system users are considered trusted (trusted_users). More on these options – in Exim documentation.
169```
170domainlist local_domains = @ : example.org : ${lookup mysql{VIRTUAL_DOMAINS}} : ${lookup mysql{ALIAS_DOMAINS}}
171domainlist relay_to_domains = ${lookup mysql{RELAY_DOMAINS}}
172hostlist   relay_from_hosts = localhost : @ : 192.168.0.0/24
173#trusted_users = www-data
174```
175These lines configure database connectivity. You need to uncomment one of them (depending on the database type you have chosen) and adjust it to match your setup. You at least have to change the word 'CHANGE' to the password you used for the 'vexim' database user, which you have created before. The socket path depends on your system, for Debian it is:
176```
177#hide mysql_servers = localhost::(/var/run/mysqld/mysqld.sock)/db/user/password
178#hide pgsql_servers = (/var/run/postgresql/.s.PGSQL.5432)/db/user/password
179```
180If you want to use either Anti-Virus scanning, or SpamAssassin, you will need to uncomment the appropriate line here.
181```
182# av_scanner = clamd:/tmp/clamd
183# spamd_address = 127.0.0.1 783
184```
185in Debian use:
186```
187# av_scanner = clamd:/var/run/clamav/clamd.ctl
188# spamd_address = /var/run/spamd.sock
189```
190Specify here, the username and group under which Exim runs (Debian: `Debian-exim`). This combination is also that under which mailman must run in order to work:
191```
192exim_user = mailnull
193exim_group = mail
194```
195Also it is assumed that the mysql domain socket is /tmp/mysql.sock, which is where the FreeBSD port puts it. Other installations put it in /var/tmp, /usr/lib, or any number of other places. If yours isn't /tmp/mysql.sock, you will need to set this.
196
197TLS is activated by default. We suppose that you already created a SSL key and certificate.
198```
199tls_certificate = /etc/exim4/exim.crt
200tls_privatekey = /etc/exim4/exim.key
201```
202The creation of SSL-keys is the same like for webservers, e.g. https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-with-a-free-signed-ssl-certificate-on-a-vps . You can use the same certificate your the webserver of this host (if you use webmail).
203
204```
205tls_dhparam = /etc/exim4/dhparam.pem
206```
207The Diffie-Hellman group should have at least 1024 bit and can be created with this command (it can take some time):
208```
209# openssl dhparam -out /etc/exim4/dhparam.pem 2048
210```
211In `tls_require_ciphers`, currently (2016) secure ciphers are selected. It works by default on GnuTLS setups (Debian/Ubuntu). If your distribution uses OpenSSL (e.g. FreeBSD, CentOS), comment the block `tls_require_ciphers = ...` and uncomment the line `openssl_options = ...`. If you are not sure, the output of `exim -bV` will show either GnuTLS or OpenSSL.
212
213
214###### ACL's:
215We have split all of the ACL's into separate files, to make managing them easier. Please review the ACL section of the configure file. If there are ACL's you would rather not have executed, please comment out the '.include' line that references them, or edit the ACL file directly and comment them out.
216
217###### DEBIAN:
218Typically, Debian setups use split Exim configuration with some Debconf magic. This manual will assume that you are familiar with it. If not, you should refer to the Debian documentation on Exim. To get the virtual mailboxes to work, copy the contents of docs/debian-conf.d/ to /etc/exim4/conf.d/ and change the MySQL password in .../main/00_vexim_listmacrosdefs. You may also want to review the ACL's in docs/vexim-acl-*.conf and selectively copy and paste their contents to the files provided by Debian in conf.d. By the way, some of these ACL's are already implemented by Debian, so you might just need to enable them by defining certain macros as described in Debian manual. This manual does not cover enabling ClamAV and SpamAssassin in Exin in Debian. Please look this up elsewhere. By the way, the author of this part never bothered to set up Vexim in such a way that Debian would take into account the status of the various user flag (on_av, on_spamassassin etc) for each user. In his setup, these flags have no effect, and all messages are checked for spam and viruses.
219
220Stefan Tomanek has a nice writeup about using Vexim in Debian, but that article does not cover all aspects, is a bit outdated, and most of if has been incorporated (and improved!) into this document anyway. You can find it at http://stefans.datenbruch.de/rootserver/vexim.shtml.
221
222
223## Site Admin:
224In order to add and delete domains from the database, you need to have a "site admin". This user can create the initial postmaster users for the individual domains. This user has been created along with the database (see mysql-section), use it here to log in. The password is case sensitive. You are advised to change it when you first log in.
225
226## Virtual Domains:
227Virtual Exim can now control which local domains Exim accepts mail for and which domains it relays mail for. The features are controlled by the siteadmin, and domains can be easily added/removed from the siteadmin pages. Local domains can also be enabled/disabled on the fly, but relay domains are always enabled.
228
229
230## Mail storage and Delivery:
231The mysql configuration assumes that mail will be stored in /var/vmail/domain.com/username/Maildir. If you want to change the path from '/var/vmail/', you need to edit the file:
232>vexim/config/variables.php
233
234and change 'mailroot' to the correct path. Don't forget the / at the end.
235
236## POP3 and IMAP daemons:
237There are many POP3 and IMAP daemons available. Some that we have found that work are:
238
239* **Courier:** docs/clients/courierimap.txt
240* **Dovecot:** docs/clients/dovecot.txt
241
242Dovecot provides more features (server-side sieve filters) and is more performant on larger setups.
243
244**UPGRADING:** If you are upgrading, you will need to update your configs for your POP/IMAP daemons, as the database layout has changed. You should be able to follow the above instructions without problem.
245