We study a model which can describe a superconducting single-electron transistor or a double quantum dot coupled to a transmission-line oscillator. In both cases the degree of freedom is given by a charged particle, which couples strongly to the electromagnetic environment or phonons. We consider the case where a lasing condition is established and study the dependence of the average photon number in the resonator on the spectral function of the electromagnetic environment. We focus on three important cases: a strongly coupled environment with a small cutoff frequency, a structured environment peaked at a specific frequency, and 1/f noise. We find that the electromagnetic environment can have a substantial impact on the photon creation. Resonance peaks are in general broadened and additional resonances can appear.