A man from the Muslims sought permission from the Messenger of Allah ﷺ to marry a woman called Umm Mahzul. She used to commit fornication, and she would stipulate as a condition for any man who married her that she would provide his maintenance. He asked the Messenger of Allah's ﷺ permission, or mentioned her situation to him.The Prophet of Allah ﷺ then recited to him, "And the fornicatress, none marries her except a fornicator or a polytheist" [Nur 24:3].
أن رجلا من المسلمين استأذن رسول الله ﷺ في امرأة يقال لها: أم مهزول وكانت تسافح، وتشترط للرجل يتزوجها أن تكفيه النفقة، فاستأذن رسول الله ﷺ، أو ذكر له أمرها. قال: فقرأ عليه نبي الله ﷺ: {والزانية لا ينكحها إلا زان أو مشرك} [النور: ٣].
Ahmad (6480), Hakim (2/193–194), and Bayhaqi (7/153) all narrated it from Mutamir bin Sulayman, his father said, Hadrami narrated to us from Qasim bin Muhammad, from Abdullah bin Amr, and he mentioned it.Hakim said, "sahih isnad."Hadrami here is the storyteller who was in Basra, not Hadrami bin Lahiq Yamami. Ibn Main said of him, "There is no harm in him," and Ibn Adi, after citing three of his hadiths, this one among them, said, "I hope there is no harm in him." As for Ibn Madini's statement that he is majhul, it should be understood in light of the scarcity of his narrations. As for Hadrami bin Lahiq Yamami who appears in Hakim's isnad, he is trustworthy and well known.