We study the decoupling process of neutrinos in the early universe in the presence of
three-flavour oscillations. The evolution of the neutrino spectra is found by solving the
corresponding momentum-dependent kinetic equations for the neutrino density matrix,
including for the first time the proper collision integrals for both diagonal and off-diagonal
elements.
We find that the contribution of neutrinos to the cosmological energy density
in the form of radiation,
in terms of the effective number of neutrinos, is $N_{\rm eff}=3.045$. This result does not depend on the ordering of neutrino masses, it is
in agreement with previous theoretical calculations and consistent with the latest analysis of Planck data.
We also calculate the effect of non-standard neutrino-electron interactions (NSI), predicted in many theoretical models where neutrinos acquire mass. For two sets of NSI parameters allowed by present data, we find that $N_{\rm eff}$ can be reduced down to $3.040$ or enhanced up to
$3.059$. Finally, we consider the case of very low reheating scenarios ($T_{\rm RH}\sim\mathcal{O}({\rm MeV})$), where the thermalization of neutrinos can be incomplete ($N_{\rm eff}<3)$ and leads to a lower bound on the reheating temperature, $T_{\rm RH} > 4.7$ MeV from Planck data (95\% CL).