Einstein's special theory of relativity states that the total energy of a particle with mass is:
mc^ 2
E = -----------------
sqrt [ 1 - (v/c)^2]
Here, m is the rest mass, i.e. the mass of the particle when it is at rest. v is the velocity, and c is the speed of light. When we do a series expansion of the above equation, we get:
E = mc^2 + 1/2 mc^2 (v/c )^ 2 + ...
= mc^2 + 1/2 mv^2 + ...
What does this tell us? If v equals zero, the equation becomes the famous E=mc^2, which states that a particle at rest has a total energy equal to its mass times the speed of light squared. If you completely annihalated this mass, this is how much energy would be obtained.
Now, if you are familiar with Newtonian mechanics, the second term should look awfully familiar. It is the expression for the kinetic energy of a moving body. In relativity, we group the parts of the above equation into three terms, all in units of energy:
E = M + P
Where:
E : total energy
M = mc^2 : rest energy (mass)
P = 1/2 m v^2 + ... = cp : kinetic energy (momentum)
Now, if a particle (such as a photon) is massless , the term M goes to zero. So we end up with simply:
E = P
This means that all of the particle's energy goes into motion. There is no rest mass because it is impossible to ever view the particle at rest (because it travels at the speed of light, c).