Photons only have mass by virtue of its movement. There are 2 types of mass. Relativistic mass, and ress mass. Photons have 0 mass when they are at rest (which they cannot be, v = c for photons). But photons have energy, which is "equivalent" to mass. That is why when you near the speed of light, your mass increases. Because all that really happens is your Kinetic Energy increases, and because Kinetic Energy has mass, your mass increases
The notion of a relativistic mass that increases with velocity arose early in SR, but it is now archaic. The energy and momentum of any object form a Lorentz four-vector, whose invariant length squared is given by
m^2=E^2-p^2 (with c=1). This invariant length, m, is defined as the mass of the object. The photo has zero mass so E=p for a photon.
In GR, it is the energy and momentum (in the form of the stress-energy tensor T_\mu\nu) that produces and reacts to gravitation. So massles phtons interact gravitationally.