There appears to be an issue when using Debian 11 where spamassassin won't register to start at boot, and even in a post-install rebooted state, will not be running. Perhaps I am incorrect, but I think this is a useful addition that makes sure this is all set up to operate as you intended. I am not much of a systemd guy, but I think this is the correct way to do this. It appears to work on a server I used this script on. Please reject if superfluous or unnecessary.
Thanks for your work automating the "really fun" part of all this!
Ubuntu can't run multiple lines without a special character, thus making the script malfunction, putting the commands on the same line solves the problem and the script can be used on Ubuntu 20.04
According to the wiki (https://wiki.dovecot.org/SSL/DovecotConfiguration):
"From version 2.3, you must specify path to DH parameters file using:
ssl_dh=</path/to/dh.pem"
This actually threw an error something along the lines of: "imap-login: Error: Failed to initialize SSL"
The main command for generating DKIM keys (`opendkim`) wasn't installed with just the `opendkim` package. Added a fix so it would be installed should it not be there the first time `apt` is ran.