E = mc2 is the special case of E2 = ρ2c2 + m2c4 , Its a combination of mass energy and momentum energy. The mass of photon is 0, so they get all their energy from momentum, Energy of photon reduces to E = ρc . e.g. A rope connected to an object in one end, when other end of the rope is shook violently it can move/jerk the object in other end i.e. the rope did not carry any mass but transferred energy in the form of wave motion. The same way the photons transfer energy.