Articles with the tag:
Close
Changelog
Close
Help Center
Mail Server for Docker

Installing Mail Server for Docker on a local server

Mail Serverv.1.6 Mail Server changelog

Version 1.6.25

Release date: 07/03/2017

Runtime

  • Updated OpenSSL to the latest version (1.0.2).

Version 1.6.21

Release date: 04/26/2017

Runtime

  • Fixed the issue when the amavisd-new interface could not start without the properly configured IPv6.

Version 1.6.20

Release date: 12/13/2016

Connection Settings

  • Added page to the Settings for the integration of Community Server (Windows version) with Mail Server.

Installation Script

  • Fixed the error shown if the mail domain is not specified, now Mail Server will not be installed if this is the case.

Version 1.6.7

Release date: 06/22/2016

Refactoring

  • Removed version from the iRedMail folder;
  • iRedMail completed with commits from v.0.9.2;
  • Deleted unused packages from iRedMail;
  • Added the SpamAssassin setup with initial bayes_tokens.

Runtime

  • Fixed the incorrect MySQL server name in the config;
  • Fixed the issue with the config section duplication when starting the Docker container;
  • Fixed the issue with sending mail to a group/alias address;
  • Fixed the startup API issue.

Logging

  • Fixed logging during the installation.

Networking

  • Fixed the fail2ban and iptables issue when starting Docker in a network mode;
  • Fixed the issue with Mail Server on an external physical server.

Version 1.6.0

Release date: 03/09/2016

Settings

  • Redesigned Mail Server settings page.

Version 1.5.0

Release date: 04/20/2015

Mail Server

  • Mail Server for Docker first release.

Introduction

Mail Server is a full-featured mail server solution developed on the base of the iRedMail package, containing the following components: Postfix, Dovecot, SpamAssassin, ClamAV, OpenDKIM, Fail2ban.

Integrated with Community Server, Mail Server allows you to:

  • connect your own domain name;
  • create mailboxes;
  • add aliases for each mailbox;
  • create mailbox groups.

This guide will show you how to install Mail Server Docker version to your machine.

System requirements

  • CPU
    dual core 2 GHz or better
  • RAM
    2 GB or more
  • HDD
    at least 2 GB of free space
  • Additional Requirements
    at least 2 GB of swap
  • OS
    amd64 Linux distribution with kernel version 3.10 or later
  • Additional Requirements
    • Docker: version 1.10 or later

Installing Mail Server using automatic script command

If you do not want to set everything manually, you can install Mail Server automatically using our Docker script. You can download the script using our site download page. Or the direct download link can be used, if it is more convenient for you:

wget http://download.onlyoffice.com/install/opensource-install.sh

Once the download is finished, run the following command to install Mail Server:

bash opensource-install.sh -ics false -ids false -icp false -ims true -md yourdomain.com -es true

Installing Mail Server manually

If you prefer to have full control of what and how is being installed, you can run the installation in manual mode. To do that follow the steps below.

Installing prerequisites

You need the latest Docker version installed. If you do not have it, please see the Installation section on Docker website to learn how to get it.

Docker specifies Google DNS servers by default. If your Community Server is not going to have access to the Internet, we recommend that you change the default Docker DNS address to the address of your local DNS server. To do that go to the /etc/default/docker file and change the IP address in the following line to the IP address of a DNS server in your local network:
docker_OPTS="--dns 8.8.8.8"

Before you start the installation you need to create the following folders:

  1. For MySQL server
    sudo mkdir -p "/app/onlyoffice/mysql/conf.d";
    sudo mkdir -p "/app/onlyoffice/mysql/data";
    sudo mkdir -p "/app/onlyoffice/mysql/initdb";
    
  2. For Community Server data and logs
    sudo mkdir -p "/app/onlyoffice/CommunityServer/data";
    sudo mkdir -p "/app/onlyoffice/CommunityServer/logs";
    
  3. For Document server data and logs
    sudo mkdir -p "/app/onlyoffice/DocumentServer/data";
    sudo mkdir -p "/app/onlyoffice/DocumentServer/logs";
    
  4. And for Mail Server data and logs
    sudo mkdir -p "/app/onlyoffice/MailServer/data/certs";
    sudo mkdir -p "/app/onlyoffice/MailServer/logs";
    

Then create the onlyoffice network:

sudo docker network create --driver bridge onlyoffice
Installing MySQL

After that you need to create MySQL server Docker container. Create the configuration file:

echo "[mysqld]
sql_mode = 'NO_ENGINE_SUBSTITUTION'
max_connections = 1000
max_allowed_packet = 1048576000" > /app/onlyoffice/mysql/conf.d/onlyoffice.cnf

Create the SQL script which will generate the users and issue the rights to them. The onlyoffice_user is required for Community Server, and the mail_admin is required for Mail Server in case it is going to be installed:

echo "CREATE USER 'onlyoffice_user'@'localhost' IDENTIFIED BY 'onlyoffice_pass';
CREATE USER 'mail_admin'@'localhost' IDENTIFIED BY 'Isadmin123';
GRANT ALL PRIVILEGES ON * . * TO 'root'@'%' IDENTIFIED BY 'my-secret-pw';
GRANT ALL PRIVILEGES ON * . * TO 'onlyoffice_user'@'%' IDENTIFIED BY 'onlyoffice_pass';
GRANT ALL PRIVILEGES ON * . * TO 'mail_admin'@'%' IDENTIFIED BY 'Isadmin123';
FLUSH PRIVILEGES;" > /app/onlyoffice/mysql/initdb/setup.sql
Please note, that the above script will set permissions to access SQL server from any domains (%). If you want to limit the access, you can specify hosts which will have access to SQL server.

Now you can create MySQL container setting MySQL version to 5.7:

sudo docker run --net onlyoffice -i -t -d --restart=always --name onlyoffice-mysql-server \
 -v /app/onlyoffice/mysql/conf.d:/etc/mysql/conf.d \
 -v /app/onlyoffice/mysql/data:/var/lib/mysql \
 -v /app/onlyoffice/mysql/initdb:/docker-entrypoint-initdb.d \
 -e MYSQL_ROOT_PASSWORD=my-secret-pw \
 -e MYSQL_DATABASE=onlyoffice \
 mysql:5.7
Installing Mail Server

After you have everything ready, execute the following command:

sudo docker run --init --net onlyoffice --privileged -i -t -d --restart=always --name onlyoffice-mail-server -p 25:25 -p 143:143 -p 587:587 \
 -e MYSQL_SERVER=onlyoffice-mysql-server \
 -e MYSQL_SERVER_PORT=3306 \
 -e MYSQL_ROOT_USER=root \
 -e MYSQL_ROOT_PASSWD=my-secret-pw \
 -e MYSQL_SERVER_DB_NAME=onlyoffice_mailserver \
 -v /app/onlyoffice/MailServer/data:/var/vmail \
 -v /app/onlyoffice/MailServer/data/certs:/etc/pki/tls/mailserver \
 -v /app/onlyoffice/MailServer/logs:/var/log \
 -h yourdomain.com \
 onlyoffice/mailserver

Where yourdomain.com is your mail server hostname.

Your domain that will be used for maintaining correspondence must be valid and configured for this machine (i.e. it should have the appropriate A record in the DNS settings that points your domain name to the IP address of the machine where Mail Server is installed).
In the command above, the "yourdomain.com" parameter must be understood as a service domain for Mail Server. It is usually specified in the MX record of the domain that will be used for maintaining correspondence. As a rule, the "yourdomain.com" looks like mx1.onlyoffice.com

In this case the mail server will ensure the mail delivery to internal addresses hosted on this server.

Storing data outside containers

All the data are stored in the specially-designated directories, data volumes, at the following location:

  • /var/log for Mail Server logs
  • /var/lib/mysql for MySQL database data
  • /var/vmail for mail storage
  • /etc/pki/tls/mailserver for certificates
We recommend We strongly recommend that you store the data outside the Docker containers on the host machine as it allows you to easily update Mail Server once the new version is released without losing your data.

To get access to your data located outside the container, you need to mount the volumes. It can be done by specifying the -v option in the docker run command.

sudo docker run --privileged -i -t -d -p 25:25 -p 143:143 -p 587:587 \
        -v /app/onlyoffice/MailServer/logs:/var/log  \
        -v /app/onlyoffice/MailServer/mysql:/var/lib/mysql  \
        -v /app/onlyoffice/MailServer/data:/var/vmail  \
        -v /app/onlyoffice/MailServer/data/certs:/etc/pki/tls/mailserver -h yourdomain.com onlyoffice/mailserver
Please note, that in case you are trying to mount the folders which are not yet created, these folders will be created but the access to them will be limited. You will need to change their access rights manually.

Storing the data on the host machine allows you to easily update Mail Server once the new version is released without losing your data.

Configuring Docker image

To ensure the mail delivery to internal addresses as well as addresses of external servers you need to get your own domain name and configure a DNS server.

The following DNS records are required:

  • A record (used to point a domain to the IP address of the host where this docker image is deployed).
  • Pointer (PTR) record or a reverse DNS record (used to map a network interface (IP) to a hostname).
sudo docker run --privileged -i -t -d -p 25:25 -p 143:143 -p 587:587 \
-v /app/onlyoffice/MailServer/data/certs:/etc/pki/tls/mailserver -h yourdomain.com onlyoffice/mailserver

Where yourdomain.com is your mail server hostname.

Installing the SSL certificates

The self-signed certificates for your domain will be created by default while running the docker container. If you want to use CA sertified certificates, you will need to rename them and copy into the /app/onlyoffice/MailServer/data/certs directory before running the image. The following files are required:

  • /app/onlyoffice/MailServer/data/certs/mail.onlyoffice.key
  • /app/onlyoffice/MailServer/data/certs/mail.onlyoffice.crt
  • /app/onlyoffice/MailServer/data/certs/mail.onlyoffice.ca-bundle

You can copy the SSL certificates into the /app/onlyoffice/MailServer/data/certs directory after running the image. But in this case you will need to restart the docker container.

Available configuration parameters
Please refer the docker run command options for the `--env-file` flag where you can specify all required environment variables in a single file. This will save you from writing a potentially long docker run command.

Below is the complete list of parameters that can be set using environment variables.

  • STORAGE_BASE_DIR: The path to the mail store. Defaults to /var/vmail.
  • FIRST_DOMAIN: The first virtual domain, where the postmaster address will be hosted. This domain should not coincide with the primary mail server domain. Defaults to mailserver.onlyoffice.com.
  • DOMAIN_ADMIN_PASSWD: The postmaster password. The default postmaster address is postmaster@mailserver.onlyoffice.com.

Installing Mail Server integrated with Document and Community Servers

Mail Server is a part of ONLYOFFICE Community Edition that comprises also Document Server and Community Server. In case you want to install all of them and integrate with each other, read these instructions.

Alternative ways to install Mail Server

Alternatively, you can use an automatic installation script to install the whole Community Edition at once. For the mail server correct work you need to specify its hostname yourdomain.com.

STEP 1: Download the installation script file

Assuming you have docker-compose installed, execute the following command:

wget http://download.onlyoffice.com/install/opensource-install.sh
STEP 2: Install Community Edition

Run the following command to do that:

bash opensource-install.sh -md yourdomain.com
Download Host on your own server Available for Docker,
Windows, Linux and virtual machines
You Might Also Like This:
Close