../mox-in-local-qemu-vm

Starting mox in qemu

Published:


<This guide assumes you're using linux and have qemu installed>

Mox is a simple easy to use all one in blah blah its used for email just look at its website. This is a quick guide on running it in qemu.

You don't have to have a domain or anything to run mox locally and send mails to yourself at all, so this is for those trying to get into hosting their own email but don't have a VPS/server or domain setup yet (like me!).

Step 1

Get a virtual machine running with qemu and install your favouriteā„¢ distro, heres a quick tutorial on qemu, get the ISO image of the distro and;

First run qemu-img to create the virtual disk for the VM:

qemu-img create -f qcow2 DISKNAME qcow2 32G

Then run the freshly downloaded ISO of your distro with:

qemu-system-x86_64 -accel kvm -m 4G -cpu host -smp 8 \
  -nic user,model=virtio-net-pci \
  -drive file=/path/to/DISKNAME.qcow2,media=disk,format=qcow2,if=virtio \
  -drive file=/path/to/isofile.iso,media=cdrom,readonly=yes
  -boot menu=on,cd

Inside the VM install the distro as normal. And restart into the VM again by removing the isofile.iso line from the qemu invokation. But in addition to that we need to do something special, we need to port forward all the ports mox will use with localserve to host ports, for that we use the hostfwd= option of -nic so in the above qemu invocation replace the -nic line with

  -nic user,model=virtio-net-pci,hostfwd=tcp::9393-:993,hostfwd=tcp::4650-:465,hostfwd=tcp::8080-:1080,hostfwd=tcp::11443-:1443,hostfwd=tcp::11993-:1993,hostfwd=tcp::11465-:1465,hostfwd=tcp::11143-:1143,hostfwd=tcp::11587-:1586

The obove invokation port forwards the port 993 inside the VM to port 9393 on host machine same for rest of the ports, these ports are used by mox to serve email and the webmail, see below:

Step 2

Get mox by either downloading the binary from Github or installing from your distro. Just take a look at the install section.

After downloading mox inside the VM just do sudo ./mox localserve now hit Ctrl+c and edit the freshly created /root/.config/mox-localserve/mox.conf. Change 127.0.0.1 in local > IPs section to 0.0.0.0 to use the loopback device and restart mox again sudo ./mox localserve.

Now you should see all the ports mox will use for email and webmail on the VM screen, so for example to access the admin webmail (which is using port 1080 inside the VM) type http://localhost:8080/admin/ in your web browser and the admin interface should open up now enter the password (for localserve command its moxadmin) and you should login into the admin interface.

Step 3

Now to configure your local email client to use mox. In this example I will be using evolution but you will have to translate the steps for your own email client.

Upon "done" evolution should ask for the password (which is moxmoxmox for localserve). Now try sending an email to yourself (mox@localhost) and you should receive it successfully :)

Happy emailing.