Machine for dispensing coffee comprising: - at least one pump; - at least one heating device; - at least one delivery group, wherein said at least one pump is adapted to send pressurized water to said at least one delivery group, and said heating device is adapted to heat said water sent to said at least one delivery group; - at least one container of coffee powder which can be associated with said at least one delivery group; - a dispensing opening adapted to deliver, into a cup, coffee obtained by percolating said pressurized heated water through a dose of coffee powder contained in said container, wherein said coffee comprises liquid coffee and coffee cream; characterized in that it comprises, in proximity to said dispensing opening, a coffee quality optical sensor adapted to intercept a coffee flow exiting said dispensing opening, said optical sensor comprising a radiation source adapted to generate a radiation which strikes said coffee flow exiting said dispensing opening along an irradiation direction incident to the exit direction of said coffee flow, said optical sensor further comprising at least one front photodiode placed substantially along said irradiation direction on a side opposite to said radiation source with respect to said coffee flow exiting said dispensing opening, said at least one front photodiode generating a first electrical signal depending on the part of the radiation that crosses said coffee flow exiting said dispensing opening, said machine for dispensing coffee further comprising a processing and control unit connected to said optical sensor configured to receive said first electrical signal, said processing and control unit being adapted to process said first electrical signal and to generate a signal indicative of the properties of said coffee cream present in said coffee flow exiting said dispensing opening and/or a signal proportional to the extraction of coffee in said liquid coffee present in said coffee flow exiting said dispensing opening. - at least one pump; - at least one heating device; - at least one delivery group, wherein said at least one pump is adapted to send pressurized water to said at least one delivery group, and said heating device is adapted to heat said water sent to said at least one delivery group; - at least one container of coffee powder which can be associated with said at least one delivery group; - a dispensing opening adapted to deliver, into a cup, coffee obtained by percolating said pressurized heated water through a dose of coffee powder contained in said container, wherein said coffee comprises liquid coffee and coffee cream; characterized in that it comprises, in proximity to said dispensing opening, a coffee quality optical sensor adapted to intercept a coffee flow exiting said dispensing opening, said optical sensor comprising a radiation source adapted to generate a radiation which strikes said coffee flow exiting said dispensing opening along an irradiation direction incident to the exit direction of said coffee flow, said optical sensor further comprising at least one front photodiode placed substantially along said irradiation direction on a side opposite to said radiation source with respect to said coffee flow exiting said dispensing opening, said at least one front photodiode generating a first electrical signal depending on the part of the radiation that crosses said coffee flow exiting said dispensing opening, said machine for dispensing coffee further comprising a processing and control unit connected to said optical sensor configured to receive said first electrical signal, said processing and control unit being adapted to process said first electrical signal and to generate a signal indicative of the properties of said coffee cream present in said coffee flow exiting said dispensing opening and/or a signal proportional to the extraction of coffee in said liquid coffee present in said coffee flow exiting said dispensing opening.