  In this work we calculate the closed time path (CTP) generating functional
for the electromagnetic (EM) field interacting with inhomogeneous anisotropic
matter. For this purpose, we first find a general expression for the
electromagnetic field's influence action from the interaction of the field with
a composite environment consisting in the quantum polarization degrees of
freedom in each point of space, at arbitrary temperatures, connected to thermal
baths. Then, we evaluate the generating functional for the gauge field, in the
temporal gauge, by implementing the Faddeev-Popov procedure. Finally, through
the point-splitting technique, we calculate closed expressions for the energy,
the Poynting vector and the Maxwell tensor in terms of the Hadamard propagator.
We show that all the quantities have contributions from the field's initial
conditions and also from the matter degrees of freedom. Throughout the whole
work we discuss and give insights about how the gauge invariance must be
treated in the formalism when the EM field is interacting with inhomogeneous
anisotropic matter. We study the electrodynamics in the temporal gauge,
obtaining the EM field's equation and a residual condition. Finally analyze the
case of the EM field in bulk material and also discuss several general
implications of our results in relation with the Casimir physics in a
nonequilibrium scenario.
