If you take Einstein's equation E = m c^2 , where m = mass and c = speed of light, and the Planck equation for the energy of a photon, E = h f , where h = Planck's constant and f = the frequency of the photon, and combine them you get: m c^2 = hf or that m = h f/c^2. This equation says that the energy carried by a photon which has NO REST MASS, is equivalent to an amount of ordinary mass in grams, and that this 'effective mass' varies with the frequency of the photon. This effective mass can be acted upon by gravity which only cares how much mass a particle has; alternately, gravity only cares about how much mass or EQUIVALENT ENERGY a particle has given by E = m c^2. Also, if you prefer the particle description of physics over the wave description, you can approximate all photons as 'bullets' each carrying a mass of m = hf/c^2 and traveling at the speed of light.