We solved it by editing the two-factor plugin on our server to “two-factor_disabled” to disable it while we set up a new one to work with the new emails.
I forgot that the mail that sends out the verification codes is one of ours, as we host ourselves, so the problem may be that we forgot to update that mail with the correct ports etc. I will try that first.