If the donor's only source of income is Haram then it is not permissible to accept his/her donation for the benefit of the Masjid.
If the donor's income is mixed with Halal and Haram while Halal income is more than the Haram then it will also be permissible to accept such person's donation.
If the donor's income is mixed with Halal and Haram while Haram income is greater than the Halal then it would not be permissible to accept the donation unless the donor specifies that the donation is not from the Haram income. Rather, it is from the money that he either received as inheritance, gift, award or loan.
If the donor's only source of income is from Haram and he wishes to donate but can not find Halal funds then he may be told to take a loan and donate from there and then repay the loan with his own money. If he donates from the loan money then the it will be allowed to accept the donation. (Imdad-ul Mufteen, Mufti Shafi Usmani R.A)
And Allah knows best.
Mufti Ikram ul Haq
Fatwa Center of America
26 Dhul-Qa'dah 1432/ October 24 2011