Notes:
I would highly recommend making a backup and testing this first. (Use your mac to edit and confirm it works).
You will need to use su to replace the file contents.
Still looking but even with a reboot, it serves the original file. I am guessing that at some point it must run a script to convert ios-profile.xml to the mailinabox.mobileconfig
Just edit the mailinabox.mobileconfig you downloaded in a text editor and then publish it on your website. You can publish it by going to /home/user-data/www/default/ and it would be served at domain.tld/mailinabox.mailconfig