Now I want to settle the matter so that I will not be accountable for it; can I give it to charity with the intention of the reward going to the person who deposited it? May Allaah reward you with good.
Praise be to Allaah.
The arrival of this money in your account may have been a mistake or it may have been deliberate. If it was deliberate -- which is unlikely -- then it is money that the owner did not want and he gave it to you, so you are entitled to take it. If it was a mistake, which is what seems to be the case, then it must be returned to its owner. If it is not possible to find out who the owner is, then you should give it in charity on his behalf, on the basis that if you find out someday who the owner is, you will give him the choice between approving of that charity or taking the money.
Shaykh al-Islam Ibn Taymiyah (may Allaah have mercy on him) said:
If he has money and does not know who its owner is, such as one who seized it by force and has repented, or one who betrayed another and has repented, or one who dealt in riba and has repented, and so on, who now have money in their possession which does not belong to them and do not know who it belongs to, then he may dispose of it by giving it to the needy and spending it in the interests of Muslims. Al-Fataawa al-Kubra (4/220),
And he (may Allaah have mercy on him) was asked about pilgrims who encountered some Bedouin who had raided some people on the road and taken their fabric; the bandits fled and left behind their camels and the fabric. Is it permissible to take the camels that belong to the thieves and the fabric that they stole, or not?
Praise be to Allaah. Whatever they took of people’s wealth must be returned to them if possible. This is like lost property which should be announced for the year. If its owner comes, all well and good, otherwise the finder may spend it on the condition that he guarantee (to replace it or compensate the owner if he shows up).
If there is no hope of finding the owner, then he should give it in charity and spend it on the interests of the Muslims.
The same applies to any property whose owner is not known, such as property that was seized by force, borrowed items, items left in trust with another, and stolen wealth seized from thieves or lost property that is found. All of this should be given in charity or spent on the interests of the Muslims. Majmoo’ al-Fataawa (30/413)
And Allaah knows best.