Voluntary agreements with industry offer many examples of overcompliance with respect to environmental standards. Such phenomena seem to be irrational but appear less surprising considering firms' strategies are aimed to internalise environmental quality. We model the choice of the environmental quality of products in a one-shot game between a monopolist and consumers, to show the existence of inefficient equilibria where quality is low because of moral hazard. The firm can however change its equilibrium strategy in a repeated but finite game, in order to build an environmental reputation if we suppose that consumers' information is not only imperfect with regard to quality, but also incomplete with respect to any environmental constraint that may affect the behaviour of firms (like the threat either of a stricter regulation or of potential entry). In a two-periods model we show the existence of a perfect Bayesian equilibrium in mixed strategies where the firm can revert to the production of green products in order to influence consumers' beliefs and acquire an environmentally friendly reputation. Due to the peculiarity of environmental information (green products are credence goods), we claim that an explicit agreement is also necessary in order to establish monitoring and controlling procedures to verify the performance of firms. These procedures can explain per se the diffusion of voluntary agreements that are nevertheless self-enforcing because of the reputation effect.