All perfect praise be to Allah, The Lord of The Worlds, and may His peace and blessings be upon our Prophet Muhammad and upon all of his family and companions.
Islam has specified the lawful methods for earning money and spending it as well clarified the prohibition of ill-gotten money earnings upon a Muslim.
In addition, making something lawful or unlawful in Islam depends on its nature; bad (impure) or good (pure). Accordingly, all the bad things or items are unlawful and all the good things or items are lawful, for Allah, The Exalted Said (What means):” he allows them as lawful what is good (and pure) and prohibits them from what is bad (and impure).” [Al-Araf/157].
On one hand, whatever is earned through a lawful job is lawful, whereas the person is permitted to eat and give charity from his lawful earnings and will be rewarded from Allah, The Almighty. On the other hand, whatever is earned through unlawful job is unlawful, yet a person is permitted to give charity and make donation from the latter job or income so long as the purpose is to get rid of the ill-gotten money and make it lawful, besides he will be rewarded only for discarding it.
However, the end cannot justify the means, therefore a good intention of building a Mosque or establishing a charitable project doesn’t justify unlawful earnings; so whosoever makes unlawful earnings for the purpose of giving charity or making lawful job won’t be redeemed from the sin of having unlawful job, for Abu Huraira reported Allah's Messenger (PBUH) as saying (What means):” O people, Allah is Good and He therefore, accepts only that which is good. And Allah commanded the believers as He commanded the Messengers by saying: "O Messengers, eat of the good things, and do good deeds; verily I am aware of what you do"[Al-Muminun/51]. And He said: "O those who believe, eat of the good things that We gave you.” [Al-Baqarah/172]. [Related by Moslim].
In conclusion, there is no harm on accepting the aforementioned donations and spending them for the interests of the Mosque. And Allah Knows Best.