Guide to using multiple domains


I would like a box to host the e-mails from several different domains, including domain aliases.

It would be great if it were created in the Setup Guide a section teaching how to do this.

Before this section exist, can anyone help me please?
I’m lost. Do not even know where to start.

Thank you!

EDIT: I’m using Linode.


You just need to follow the instructions in the Nameservers section under Configuring Your Domain Name in the setup guide. Then just create mail users/aliases @ that domain name in the /admin page.

Not sure what you mean by domain aliases. If that’s whole domain => whole domain forwarding, I don’t think it’s supported now but it could be.


Very nice!!! Congratulations on the excellent work!

It is so easy that even seems to be just that. So then failed to make clear is that simple. :wink:

What I mean by domain alias is as follows:
A company has two domains - (main) and

If an email is sent to will be automatically directed to

Enjoying the contact, another question is about the possibility of accessing webmail using a subdomain, for example

Is it possible? What should be done?

Many thanks.


accessing webmail using a subdomain, for example

No that’s not possible.

If you get Mail-in-a-Box working and really need domain aliases, please open an issue on the github project so I don’t lose track of the request.


Just so I understand better and not spend time breaking head: it is a technical limitation that makes it impossible to use a subdomain or is your choice to make things as generic as possible?


Anything is technically possible. It’s not something the box is capable of doing.


I really do not understand why the default access is through a “folder”.

You can set the subdomain webmail for all domains using a setup similar to this:

# Redirect all HTTP to HTTPS.
server {
        listen 80;
        listen [::]:80;

        server_name webmail.*;
        root /tmp/invalid-path-nothing-here;
        rewrite ^(.*) https://$host$1 permanent;

# The secure HTTPS server.
server {
        listen 443 ssl;

        server_name webmail.*;

        ssl_certificate /home/user-data/ssl/ssl_certificate.pem;
        ssl_certificate_key /home/user-data/ssl/ssl_private_key.pem;
        include /etc/nginx/nginx-ssl.conf;

        # Expose this directory as static files.
        index index.php;
        root /usr/local/lib/roundcubemail/;

        location = /robots.txt {
                log_not_found off;
                access_log off;

        location = /favicon.ico {
                log_not_found off;
                access_log off;

        # Roundcube Webmail configuration.
        rewrite ^$ / redirect;
        rewrite ^/$ /index.php;
        location ~ /config/.* {
                # A ~-style location is needed to give this precedence over the next block.
                return 403;
        location ~ /.*\.php {
                # note: ~ has precendence over a regular location block
                include fastcgi_params;
                fastcgi_split_path_info ^(/.*)()$;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME /usr/local/lib/roundcubemail/$fastcgi_script_name;
                fastcgi_pass php-fpm;
                client_max_body_size 20M;


It’s simpler: no extra DNS records, no SSL certificate to buy.


But with LetsEncrypt is free. Where is the problem?
If webmail were in subdomain, I could set on domain’s DNS zone only the subdomain for webmail.
However, I must to enter to for all domains webmails. This is not apperars cool/good for the customers’ view.

What problem will occur to set webmail on subdomains if the LetsEncrypt is free?


Josh doesn’t want to implement this feature - if you want it, code it, PR it on github, and then you can support this specific feature :slight_smile:


Also: if the HTML is hosted on your mailinabox simply using:

all works. If it is hosted elsewhere: use PHP + Rainloop :wink:


There is an easy way to setup rainloop without broken MIAB setup to run it on the same host or we need an additional host for rainloop?


Hi! You’re in luck - I made a tutorial earlier this week on how to do this IN Mail-In-A-Box: