Quantum electrodynamics in the presence of dielectrics and conductors. IV. General theory for spontaneous emission in finite geometries | Synapse