-
Notifications
You must be signed in to change notification settings - Fork 0
Installation and Setup
The following commands should get all dependencies and install the executables:
go get -v -d github.com/FabianWe/mailwebadmin/...
go install -v github.com/FabianWe/mailwebadmin/...However, installation via docker is the preferred way.
To setup properly you need a mysql database containing your mail information. I followed the ISPmail guide for Debian Jessie (I'm planning to write a docker image for this). But there is one big difference: Currently only SHA-512 is supported instead of SHA-256. But this should be easy to fix, contact me if you need that or write the code yourself and open a pull request.
The database with the given information must exist before you start the program, you can easily create the required database with docker yourself, I'll post the docker-compose file later. For now you can:
- Simply use your own already existing database
- Create a directory
docker-entrypoint-initdb.dand in it a filemail.sql, I've uploaded this file in the repository: docker-entrypoint-initdb.d/mail.sql.
This file will create the database and the tables required for storing the mail information.
You have to create a directory containing all configuration stuff. By default the program will use the directory config in the current directory. However you can specify a different path for that.
The config file is a simple collection of name value pairs. It must be called mailconf and must be created inside your configuration directory.
The following options are allowed on the global level:
| Variable Name | Explanation | Example | Default |
|---|---|---|---|
| port | The port to run on | port = 8080 | 80 |
| maildir | The directory containing the mails. It must contain the placeholders %d that gets replaced by the domain and %n that gets replaced by the user name. If no username is given (i.e. we want the directory for a whole domain) %n gets replaced by the empty string, so this must return a valid path. I've never tested it with anything different than the default which stores mails in the format /var/vmail/DOMAIN/USER. Only important if you wish to delete directories automatically. | maildir = "/var/vmail/%d/%n" | "/var/vmail/%d/%n" |
| delete | If set to true after deleting an account the directory containing the user or domain gets deleted. The directory is constructed from maildir by replacing the appropriate parts. There is also an option to create backups first. | delete = true | false |
| backup | If set to a string that is not the empty string before deleting a directory a backup will be created. backup must then be the directory to contain those backups (as a zip file). If delete is set to false no backups will be created, so setting this to a path if delete is false does not make sense. If delete is true and this string is empty no backups will be created. | delete = "/mail_backup/" | "" |
| admin_user | If set an admin user with this name is created on startup. In this case also admin_password must be set to a valid password (at least length 6). | admin_user = "admin" | "" |
| admin_password | If set it is the password of the admin user specified by admin_user. If you set admin_user this must be set to a valid password (at least length 6). | admin_password = "my-very-secure-pw" | "" |
Example:
port = 8080
admin_user = "admin"
admin_password = "my-very-secure-pw"
Add a section [mysql] to the file to configure the database. The following options are allowed:
| Variable Name | Explanation | Example | Default |
|---|---|---|---|
| user | Name of the database user. | user = "my-db-user" | "root" |
| password | Password of the user. If not set no password will be used during authentication. | password = "my-db-password" | "" |
| dbname | Name of the database to use. | dbname = "mymailserver" | "mailserver" |
| host | Name of the database host. Defaults to "localhost" when installed locally and to "mysql" in docker. | host = "mysql" | "localhost" in local installation, "mysql" in docker |
| port | Port of the database. | port = 2222 | 3306 |
Example: Append the following to the previous example:
[mysql]
user = "my-user"
password = "secret-db-password"
Furthermore there are two timers you can change. Add a section [timers] to the configuration file.
The following options are allowed:
| Variable Name | Explanation | Example | Default |
|---|---|---|---|
| session_lifespan | The lifespan of a login session. When the user logs in via the webinterface the login is considered valid a certain amount of time. In the example this time is set to 1 day. The format must be that of Gos ParseDuration function. | session_lifespan = "1d" | 168 hours = 1 week |
| invalid_keys | There runs a daemon that removes invalid entries from the database (in order to save some space). This daemon is executed in an interval defined by this variable. In the example this interval is set to 12 hours. Again it must be a valid Go duration. | invalid_keys = "12h" | 1 day |
Example: Append the following to the previous example:
session_lifespan = "2d"
invalid_keys = "10h"
After installation in your go binary directory you should find an executable called mailwebadmin . You can start this executable to run the webserver. You should pass your config directory to the program with the option -config, e.g.
mailwebadmin -config "/mail-config"You can also pass the option api-only, in this case only the api gets started, not the webinterface (there should be not many use cases for this...). You can use mailwebadmin -help for more details.
You can use the executable mailwebadminuser to add a new admin user without the webinterface (for example if you've somehow forgotten your admin password). Use ./mailwebadminuser -help for more information.