Photons do exert force on electrons. Not sure that means they have mass. Traveling through space photons take the path of least resistance. Gravity is the curving of space, where the shortest distance between point a and point b is not a straight line. A photon takes the shortest path.