A woman came to the Messenger of Allah ﷺ and said, "Messenger of Allah, I have offered myself to you in marriage."She stood for a long time. Then a man rose and said, "Marry her to me if you have no need of her."The Messenger of Allah ﷺ asked him, "Do you have anything to give as a dowry?"He replied, "I have nothing."The Prophet ﷺ said, "Search, even for an iron ring."The man searched but found nothing.So the Messenger of Allah ﷺ asked him, "Do you know any of the Quran?"He answered, "Yes, such-and-such surah and such-and-such surah," naming them.The Messenger of Allah ﷺ said, "I have married her to you for what you know of the Quran."
أخبرنا هارون بن عبد الله قال حدثنا معن قال حدثنا مالك عن أبي حازم
أن رسول الله ﷺ جاءته امرأة فقالت يا رسول الله إني قد وهبت نفسي لك فقامت قياما طويلا فقام رجل فقال زوجنيها إن لم يكن لك بها حاجة قال رسول الله ﷺ هل عندك شيء قال ما أجد شيئا قال التمس ولو خاتما من حديد فالتمس فلم يجد شيئا فقال له رسول الله ﷺ هل معك من القرآن شيء قال نعم سورة كذا وسورة كذا لسور سماها قال رسول الله ﷺ قد زوجتكها على ما معك من القرآن
Sourcing, Bukhari reported it in "Wikalah," chapter on a woman appointing an agent (imam) in marriage, hadith no. 2310, from the hadith of Malik through this chain, and it is in the Muwatta (narrated by Yahya), 2/526, and in Kubra, hadith no. 24550.