Fork me on GitHub
< Back to Mail-in-a-Box

Mail-in-a-Box Maintenance Guide

This page covers frequently asked questions about how to configure a running Mail-in-a-Box and how to keep it up to date. For help setting up a new box, see the setup guide.

Something Went Wrong!

Is something not working right? Start here. Please follow these steps before asking a question on the discussion forum:

  1. Check your System Status Checks page in the control panel at https://box.yourdomain.com/admin. Everything should be green. Anything not green may help you diagnose the problem on your own.
  2. Re-run the setup by logging into your box (using the same ssh command that you used during setup) and running sudo mailinabox. Then check the System Status Checks page again.
  3. Restart your box by logging in with SSH and then typing sudo reboot. Once the box has started up, check the System Status Checks page again.

Please do these steps first. If you’ve done these steps, then head to the discussion forum to ask your question. In your post:

  1. Describe the problem you are having. Instead of saying “it doesn’t work”, write the error message you see, post a screenshot, or describe what you are seeing that you don’t want to be seeing.
  2. Mention that you “checked the status page, re-ran setup, and rebooted the box”, per the steps above, so that anyone answering knows what you have tried so far. If you don’t mention this, someone may ask you to do it before providing other assistance.
  3. If everything in the System Status Checks is green, mention that by saying “all checks are green”. If something isn’t green, mention it.

If you figure out the problem on your own, you are also welcome to write up your experience on the discussion forum so that it might help others.

Multiple Domain Names

Your box can host email and serve static websites for more than one domain name. To set up additional domain names, just follow three steps:

  1. Buy an additional domain name if you don’t yet own it. See the Your Domain Name section of the setup guide for tips.
  2. Configure its nameservers to be the same nameservers on your first domain name. Follow the Domain Name Configuration — Nameservers section of the setup guide for instructions.
  3. Add an email account (user) or alias on your box for the new domain name using the control panel. If you only plan to serve a website, still add an email address or alias — that’s how the box knows to handle that domain name.

Updating System Software

Mail-in-a-Box is based on a collection of other software packages provided by Ubuntu. We call these packages system software packages. These packages may have security or other functionality updates.

You should periodically update the system software on your box. The box will automatically install security updates as they are made available by Ubuntu, but your control panel will let you know if a reboot is needed or if non-security updates are available for you to install.

When indicated to do so, log into your machine with SSH (using the same ssh command that you used during setup) and then type:

sudo apt-get update && sudo apt-get upgrade

If prompted to reboot, type:

sudo reboot

We will post security advisories to our twitter account @mailinabox, the announcements section of the discussion forum, and our Slack chat (see the homepage).

Upgrading Mail-in-a-Box

You should move to the latest Mail-in-a-Box release as releases are posted, especially if an update addresses any security issues, although you do not necessarily need to do so. We will post release announcements to our twitter account @mailinabox, the announcements section of the discussion forum, and our Slack chat (see the homepage).

Check the release notes prior to updating to see what’s been changed in the latest version.

To upgrade Mail-in-a-Box to the latest release, first close any web browser pages related to your instance of Mail-in-a-Box, then log into your machine using SSH in exactly the same manner as when you were setting up the box (see the setup guide section called Setting Up The Box for a reminder of what that looked like).

Then, once logged in, run:

curl -s https://mailinabox.email/setup.sh | sudo bash

This is actually the same command you ran when setting up the box. It does upgrades too.

Moving to a New Box / Testing Backups

If you want to move your Mail-in-a-Box installation to a new machine (e.g. you’re getting more memory, getting a new IP address, etc.), or if something is horribly wrong with your box, you can easily move all of your data to a new machine. This is also the process for upgrading a Mail-in-a-Box box from version 5x or earlier on Ubuntu 18.04 to version 60 or later on Ubuntu 22.04 (see the release announcement for details).

Upgrade your old box first!

Moving your data to a new box is only supported if your existing Mail-in-a-Box box is up to date with the latest version of Mail-in-a-Box. So follow the steps in Upgrading Mail-in-a-Box above to upgrade to the latest version of Mail-in-a-Box before proceeding.

Perform one last backup on the old machine

You will be performing a backup + restore to move your data to the new box. To ensure you have a final backup, first block access to your box to all services besides SSH so that no new emails are sent or received. Log into your old machine using SSH and run:

sudo ufw reset
sudo ufw allow 22 # enable SSH access so you don't lock yourself out
sudo ufw enable

Then perform a backup to ensure you have everything backed up since the last nightly backup run. Run:

cd mailinabox
sudo management/backup.py

Create a new box

Start by creating a new Mail-in-a-Box machine: Spin up a new machine following the setup guide’s section The Machine. Use as many of the same settings as on your original box as makes sense. On Digital Ocean you will need to use the exact same name for your box as you did previously or reverse DNS won’t work.

Then follow the steps in the setup guide’s section Setting Up The Box. When you are prompted for the box’s hostname, you will need to use the hostname that you are currently using.

Clean up SSL files

When you set up a new machine, a self-signed SSL certificate will be generated. The presence of this data will cause nginx to not restart properly, so let's delete this data. Run:

 sudo rm -rf /home/user-data/ssl/* 

Restore your mail data (and other files)

Next you’ll restore your mail data and other files to the new machine.

Locating your backup secret key

Your backups are encrypted, and you will need your backup secret key to restore from the backup.

You should have already stored the backup secret key in a safe place — like in your home — per the backup instructions in the control panel. If you haven’t done that yet... now is the time! The file is located on your old box at /home/user-data/backup/secret_key.txt. Copy that file to a safe place now.

Copy that file onto your new box. Any SFTP program like FileZilla can help you with that. (SFTP is like SSH, so you will use the same login credentials as you use with SSH.)

Restoring backup files

Local backups

If you are using the default backup method, which stores backups on the box itself, then hopefully you have figured out how to periodically copy those files somewhere else safe — otherwise what’s the point!

Using any SFTP program like FileZilla (or scp if you know how) copy your backups from wherever you stored them to somewhere on your new machine. If your old box is still running, then just copy them from /home/user-data/backup/encrypted on your old box.

Then restore the files:

export PASSPHRASE=$(cat your_backup_secret_key_file.txt)
sudo -E duplicity restore --force file:///path/to/copied/files /home/user-data/
Amazon S3 backups

If your backups are stored in Amazon S3, get your account credentials handy and then run a duplicity restore:

export AWS_ACCESS_KEY_ID=paste your AWS access key ID here
export AWS_SECRET_ACCESS_KEY=paste your AWS secret access key here
export PASSPHRASE=$(cat your_backup_secret_key_file.txt)
sudo -E duplicity restore --force s3://s3.amazonaws.com/your-bucket-name/your-backup-path /home/user-data/

You may have to adjust the S3 URL depending on what AWS region you use. You can find the AWS Regions and Endpoints here

S3 compatible backups

If your backups are stored in an S3 compatible storage which is not amazon, you have to set the s3 endpoint url:

export AWS_ACCESS_KEY_ID=paste your AWS access key ID here
export AWS_SECRET_ACCESS_KEY=paste your AWS secret access key here
export PASSPHRASE=$(cat your_backup_secret_key_file.txt)
sudo -E duplicity restore --force s3://your-bucket-name/your-backup-path /home/user-data/ --s3-endpoint-url=https://host

Re-configure the box

Re-run Mail-in-a-Box setup now that your old files are back:

sudo mailinabox

Your box should be functioning now. Log into the control panel on your new box to see if things look right.

Update your DNS

Finally, update your domain name’s glue records to the new machine’s IP address (see the setup guide’s section on glue records.

DNS can take a few hours to update, so wait a while, and then see if the control panel’s status checks report any problems and that your devices are picking up mail on your new box.

(Skip this if you are just testing your backups.)