Molecular theory for resonant Rayleigh scattering