About this user
Mass--energy equivalence says that when a body has a mass, it has a certain energy, even when it isn't moving. In Newtonian mechanics, a massive body at rest has no kinetic energy, and it may or may not have other (relatively small) amounts of internal stored energy such as chemical energy or thermal energy, in addition to any potential energy it may have from its position in a field of force. In Newtonian mechanics, none of these energies (except gravitational potential energy) has any relationship to the mass.
In relativity, all the energy which moves along with the body adds up to the rest energy of the body, which is proportional to the rest mass of the body. Even a single photon traveling in empty space has a relativistic mass, which is its energy divided by c2. If a box of mirrors contains light, the mass of the box is increased by the energy of the light, since the total energy of the box is its mass.
Although a photon is never "at rest", it still has a rest mass, which is zero. If an observer chases a photon faster and faster, the observed energy of the photon approaches zero as the observer approaches the speed of light. This is why photons are massless. They have zero rest mass even though they have varying amounts of energy and relativistic mass. But, systems of two or more photons moving in different directions (as for example from an electron--positron annihilation) may have zero momentum over all. Their energy E then adds up to an invariant mass m = E/c2, when they are considered as a system.
This formula also gives the amount of mass lost from a body when energy is removed. In a chemical or nuclear reaction, when heat and light are removed, the mass is decreased. So the E in the formula is the energy released or removed, corresponding to a mass m which is lost. In those cases, the energy released and removed is equal in quantity to the mass lost, times c2. Similarly, when energy of any kind is added to a resting body, the increase in the mass is equal to the energy added, divided by c2.