How do we guess that photons have zero mass from the quantization of the EM field? I found that to guess that photons have zero mass from the quantization of the electromagnetic field I have to take into count the gauge invaiance of the field. Is it right or do I just have to calculate the momentum and the energy to prove it?
 A: There could be mathematical or aesthetic reasons for why photon has zero mass, but more importantly it is so because we observe that it has no mass. The theory that we come up with can't contradict reality (or experiments for that matter).
Aside from the argument above, classically the Lagrangian density for EM field is:
$$
{\cal{L}} = -\frac{1}{4} F^{\mu\nu} F_{\mu\nu}
$$
where $F_{\mu\nu} = \partial_\mu A_\nu - \partial_\nu A_\mu$, and $F^{0i} = E^i$, $F^{ij} = -\frac{1}{2} \epsilon^{ijk} B^k$. It is not hard to see that photon has no mass, because in quantum field theories mass term has to be of the form: $m^2 A^\mu A_\mu$.
We could try to add this term to Lagrangian density by hand, but this would violate gauge symmetry:
$$
A_\mu \rightarrow A_\mu - \frac{i}{e} \partial_\mu \alpha(x).
$$
(One can check that $F_{\mu\nu}$ is invariant under such transformation.)
A: The other answers focus on the absence of the mass term in the classical action, however, that is only half of the issue. While this can be determined from the classical action in non-interacting theories, in general that is not true. As a counter-example, consider Yang-Mills theory. It also doesn't have a mass term in the classical action. But it develops a mass gap when quantized – its excitations (glueballs) are massive.
Electrodynamics is a linear theory and can be quantized exactly. The Hilbert space is generated by the (smeared) photon creation operators
$$ a^{\dagger} (\vec{p}, s), $$
where $\vec{p}$ is the 3-momentum, and $s$ is the polarization of the photon. These are the eigenstates of the Hamiltonian with eigenvalues $|p|$:
$$ H a^{\dagger} (\vec{p}, s) \left| 0 \right> = |p| \cdot a^{\dagger} (\vec{p}, s) \left| 0 \right>. $$
Because $|p|$ is bounded from below by $0$, the quantum theory doesn't develop a mass gap.
In contrast, for a scalar field with mass $m$:
$$ H a^{\dagger} (\vec{p}) \left| 0 \right> = \sqrt{|p|^2 + m^2} \cdot a^{\dagger} (\vec{p}) \left| 0 \right>. $$
The energy spectrum is bounded from below by $m \neq 0$, so the theory has a mass gap $\Delta = m$.
Now to see that the photons are massless, act with the momentum operator:
$$ \vec{P} a^{\dagger} (\vec{p}, s) \left| 0 \right> = \vec{p} \cdot a^{\dagger} (\vec{p}, s) \left| 0 \right>. $$
We see that the photons with momentum $\vec{p}$ have energy $|p|$, which is characteristic of massless relativistic particles.
A: These statements are equivalent:


*

*A particle is massless

*A particle satisfies the wave equation $\square A = 0$

*A particle moves at the speed of light


Number 2. follows from Maxwell equations. We have to make a gauge fixing before though:
$$
\square A_\nu - \partial_\nu\,\partial^\mu A_\mu = 0\,,\qquad \partial^\mu A_\mu = 0
$$
The Lorenz gauge condition $\partial^\mu A_\mu$ can always be attained by transforming $A^{\mathrm{old}}_\mu = A_\mu + \partial_\mu \lambda$ with $\lambda$ a solution of
$$
\square \lambda = \partial^\mu A_\mu^{\mathrm{old}} \,.
$$
A particle that satisfies the wave equation necessarily moves at the speed of light because the equation in momentum space is $p^2 = 0$.
This does not require any input from quantum mechanics. It is also not a consequence of gauge invariance. Rather it's a consequence of the equations of motion. Crucially, however, gauge invariance strongly relies on the photon being massless. If the photon were to acquire a mass, then the gauge invariance would be lost.
This is because a massive vector satisfies${}^1$
$$
(\square + m^2)A_\nu - \partial_\nu\,\partial^\mu A_\mu = 0\,,\qquad \partial^\mu A_\mu = 0\,.
$$
And a Langrangian that generates such equations of motion necessarily contains a term $m^2 A^\mu A_\mu$ (as pointed out in another answer), which is not invariant under
$$
A_\mu \to A_\mu + \partial_\mu \lambda\,.
$$
Moreover, gauge invariance is actually very powerful as it survives at the quantum level and it prevents the photon to acquire a non zero mass after quantization.

$\quad {}^1$ Now the condition $\partial^\mu A_\mu = 0$ is not anymore a gauge fixing but comes from the trace part of the equations of motion.
