Does divorce occur if a man knows the woman he addresses is a non-mahram but intends the divorce for his wife?

Chapter on Explicit Divorce and Others

Al-Mughni

Book of Divorce

Book 39 · Issue 3 · Bab 2

Open in Qurani

Primary text

If a man knows the woman before him is a non-mahram but intends the divorce to apply to his wife, his wife is divorced.

Supporting text

If he does not intend the divorce to apply to his wife, the divorce does not occur.