This is a post to share what I did, in case others are searching for how to do the same.
I setup three MX records with my DNS provider, the first MX record points to my yunohost server and has priority 10, the second MX record points to the webmail server with priority 20, and the third MX record points to the backup webmail server with priority 30.
I tested that indeed, on yunohost, when I run ‘service postfix stop’, and send myself an email from another email account elsewhere, the email gets delivered to my webmail (it is working as a backup receiver).
I then wanted to add a fetchmail process, that would regularly fetch the mails from the webmail provider, and bring them into yunohost, so all my email are in one place, and in case some email accidentally got delivered to the webmail for some reason (and I wouldn’t want to miss it).
I tried to follow this guide, but I had some issues with it, so here is what I did.
I am running Yunohost on Debian 10, here are the steps I followed:
apt-get install fetchmail
Create the vmail home folder:
Add the following contents to
poll imap.migadu.com with proto imap port 993 user "youremail" there with password "yourpassword" is "youryunohostusername" here ssl mda "/usr/lib/dovecot/deliver -d %T" nokeep
For multiple email addresses, you can add multiple lines to .fetchmailrc exactly like above for each of your emails.
chown -R vmail /var/vmail
Test that its working by running,
sudo -u vmail fetchmail -v --all
You should see it connect, your emails in your webmail should now be empty, and they should all be in your yunohost email.
Create a crontab to regularly run fetchmail.
crontab -u vmail -e
*/15 * * * * * fetchmail -v --all > /var/vmail/fetchmail.log
What I like about this setup, is that my email goes directly to yunohost if everything is working, but if there is a bug, or my server goes down for some period, or I’m travelling and don’t have time to fix something, emails will still go to the backup, and I can sleep easy.
Hope this is helpful to someone! Or share any feedback. It could also be interesting to add a yunohost command or GUI interface for setting this up, similar to the way there is a yunohost command for configuring an outgoing SMTP relay.