Praise be to Allah, the Lord of the Worlds.
When a group of individuals agrees on raising a certain sum of money to be spent in their favor or someone else`s at a certain occasion, such as death or marriage, then that is lawful. Actually, it is a form of helping one another in righteousness and piety. Allah the Almighty said, "Help ye one another in righteousness and piety."{Al-Mai`dah, 2}. In addition, Abu Musa (May Allah be pleased with him) reported: Messenger of Allah (Blessings and peace be upon him) said, "When the Ash'ariyun run short of food in the Jihad or when they are at home in Al-Madinah,they collect all the provisions they have in a sheet and then divide it equally among themselves. They are of me and I am of them." [Al-Bukhari and Muslim].
This is provided that a person participates in this fund on voluntary basis since the paid sum is a donation; thus, you can`t force someone to give it. However, it is permissible to agree on excluding whoever decides not to contribute to this fund from receiving any benefit. This is in order to avoid any disagreements in the future. In addition, we recommend observing moderation concerning the expenditures made during the condolence period. And Allah the Almighty knows best.