The interaction of a fast electron with a photonic crystal is investigated by solving the Maxwell equations exactly for the external field provided by the electron in the presence of the crystal. The energy loss is obtained from the retarding force exerted on the electron by the induced electric field. The features of the energy loss spectra are shown to be related to the photonic band structure of the crystal. Two different regimes are discussed: for small lattice constants a relative to the wavelength of the associated electron excitations λ, an effective medium theory can be used to describe the material; however, for a ∼ λ the photonic band structure plays an important role. Special attention is paid to the frequency gap regions in the latter case.