The relic radiation spectrum and the thermal history of the universe