Mainstream theoretical results on voluntary contributions to public goods are inconsistent with empirical data: while standard models predict that the dominant strategy is to free-ride by not contributing to the public account, experimental research usually detects positive contributions. Moreover, the contribution magnitude has been showed to be sensitive to many features of the environment: the very same decision maker may behave differently according to the setting in which the action takes place. To account for this evidence, I modify the standard Voluntary Contribution Mechanism by adding a non-monetary reward in the decision maker’s payoff which factors in the warm-glow, that is the private emotional reward entailed by the contribution, the number of beneficiaries of the public good and the income inequality among the players. I obtain three main results. First, the decision maker’s optimal choice can be to contribute with a part of her income to the public account. Second, the optimal choice is smoothly increasing in the Marginal Per Capita Return of the public good. Third, all else equal, the optimal choice responds positively to the number of beneficiaries of the public good and negatively to the relative income of the other players. This implies that both the quantitative and the qualitative compositions of the community affect the optimal contribution. To test this last result, I develop three experimental designs: two Dictator Games adjusted for public goods aimed at exploring the relation between the voluntary contribution to a public good and the number of its beneficiaries, and a one-shot Voluntary Contribution Mechanism with asymmetric rewards to analyse the relation between the voluntary contribution and the income inequality among the players.