It is narrated from Sayyiduna Abu Hurayrah (may Allah be pleased with him) that the Prophet (peace and blessings be upon him) said: "A man said: I will give charity tonight. He went out with his charity and (unknowingly) gave it to an adulteress. In the morning people began saying that charity was now being given even to an adulteress. He said: 'Allahumma laka al-hamd' (O Allah, to You alone belongs all praise), charity to an adulteress? The next night he went out again with charity and gave it to a wealthy man. In the morning people again began saying that charity was being given even to the rich. He again said: 'Allahumma laka al-hamd' (O Allah, to You alone belongs all praise), what is happening to me? On the third night he went out again with charity and placed it in the hand of a thief. In the morning people again said that charity had been given to a thief during the night. He said: 'Allahumma laka al-hamd' (O Allah, to You alone belongs all praise), first to an adulteress, then to a rich man, and then to a thief I have given my charity. Then he was told: Your charity has been accepted. As for the adulteress, perhaps she will refrain from adultery; as for the wealthy man, perhaps he will take a lesson and begin giving charity; and perhaps the thief will take a lesson from it and refrain from stealing."
Hadith Referenceالسنن الكبرى للبيهقي / كتاب قسم الصدقات / 13252
Sayyiduna Ma'n bin Yazid al-Sulami (may Allah be pleased with him) said: I, my father and my grandfather pledged allegiance to the Messenger of Allah (peace and blessings be upon him). He (peace and blessings be upon him) proposed marriage on my behalf and married me off. And I took a dispute to him (peace and blessings be upon him): my father Yazid went out with some dinars to give in charity and left them with a man in the mosque. I came, took them and brought them to him, and he said: "By Allah, it was not you I intended with them." So I took my dispute to the Messenger of Allah (peace and blessings be upon him), and he (peace and blessings be upon him) said: "O Yazid, you have what you intended, and O Ma'n, you have what you took."
Hadith Referenceالسنن الكبرى للبيهقي / كتاب قسم الصدقات / 13253
Abu al-Juwayriyah al-Jarmi said: I heard Ma'n bin Yazid (may Allah be pleased with him) say: I took a dispute to the Messenger of Allah (peace and blessings be upon him); he (peace and blessings be upon him) proposed marriage on my behalf and married me off, and I and my grandfather pledged allegiance to him (peace and blessings be upon him). The narrator said: I said to him: "What was your dispute?" He said: A man used to frequent the mosque and give charity to people he knew. One night he came with a purse, and he assumed that I was one of the people he knew. When morning came it became clear to him, and he came to me and said: "Return it to me." I refused, and then we brought our dispute to the Messenger of Allah (peace and blessings be upon him), and he (peace and blessings be upon him) declared the charity lawful for me and said: "You have what you intended."
The Shaykh said: From this it is apparent that the one giving the charity was a stranger.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب قسم الصدقات / 13254