Nextcloud mail with local mail server

I’m trying to configure Nextcloud with local email server and am getting Request failed with status code 404, this is what I see in the logs:

I have tried using localhost, and the local IP of the server and I can confirm that the settings work in KMail (using local IP). I am using PLAIN authentication but there doesn’t seem to be an option for that in Nextcloud.