Logitech media server (squeezebox) with the don’t stop the music plugin. It can use different services for context aware playlists and I found last.fm to be a lot better than Spotify. MusicIP used to be a thing on LMS as well, and probably can still be used, that’s completely local but analyzing new tracks is slow since MusicIP servers are down (MusicIP got bought by Spotify ages ago).
Basically every serious mailserver package has imapsync included. I don’t know what kind of hardware you’re running and what you expect from the server doing the copying but running webmail, search indexes, antivirus, etc will cost you ram. There are solutions aimed at keeping backups of your mail though, I can’t give you recommendations, the only thing I remember is that they don’t give you a normal webmail or imap, instead you get a web-interface aimed at searching through the backup(s)