[qmf] Introduce discovery of authentication from the anounced capabilities(IMAP/SMTP)

You have 4 repetitions of this stanza, probably best to pull it out into a separate function.