I have wanted to have autoconfig for email accounts for a while. I’m fed up with people asking me “what port number?” etc So I wrote a little script for Hestia that helps setup the autoconfig/autodiscover functions:
Its designed for Linode servers, but the logic can be used on any (you will just need to tweak the bits with linode-cli).
Hopefully this is of use to someone - and forks/shares are much appreciated if you have any suggestions.
The linode-cli part wouldn’t be hard to change if you are using the local DNS on your server. All it needs to do is add 2 new CNAMEs pointing back to the main domain:
What it does is create a .mobileconfig file, which when downloaded on an iOS device will create a profile with the email settings. All they have to do when installing it, is enter the profile password. When I was setting up iPhone test accounts it was soooo painful entering paths (you had to keep repeating stuff, couldn’t copy and paste, etc) … so hopefully this will save some iOS users some grief!
I’m just tweaking the script so people using the local DNS server can make use of it as well. Would this be the correct format to add autoconfig/autodiscover CNAMEs for the domain?
Feel free if you have the time Unfortunatly Bash is not one of the languages I’m proficient in (I can play with it, but not write from scratch). Perl is my go-to as its the main language I program in.
format should work fine
Thanks. I’ve updated the script so the admin can tweak which DNS setting it uses:
Fantastic!! this keeps getting better!! Especially the IOS mail thats been a pain.
As @eris said we should work on converting it to a bash script as this is default with HestiaCP.
I think the logic is done at this point.
Anyone want here want to take a stab at converting to a bash script and submitting a PR? I really wish I was better at bash.
zpush sounds good but may be much more complicated to implement and it looks like the last update for zpush was back in the Feb beginning of 2021 which is almost 2 years and doesn’t support php8.0+.
This autodiscover/autoconfig may be a nice quick temp solution
I’ve done some more tweaks. It now creates a file in /installer/discover-configs-done for the domain once its been setup (so we can quickly skip). I’ve also created an add-autodiscover-all.cgi script, which is aimed at setting up the autodiscover on ALL the domains that have mail setup. The idea of this script is that it can also be setup to run on a cronjob (as root), and then when new domains are added it will simply set it up automatically (I’ve set mine to every 6 hours, but you can do what you want)
There is a bit more in the README regarding this
Hopefully someone can convert this into a bash script for others (its working great for me and all my servers)