It is incorrect to say that the energy of a string directly gives us the mass of the particle. While it is true that more the oscillations on the string, higher the mass, the relation between the oscillations and the mass it not that of a simple proportionality.
What's really happening is that the string has some energy $E$ (due to oscillations on it) and a momentum $\vec{p}$ (since it is moving in space), which is not affected by the oscillations. The mass of the particle that such a string relates to is given by the relativistic dispersion relation
$$
m = \sqrt{\frac{E^2}{c^4} - \frac{p^2}{c^2} }
$$
where $p^2 = \vec{p}\cdot\vec{p}$.
Now as you can see, it is possible to choose oscillations on the string such that $E^2 = p^2 c^2$ which gives us a zero mass particle. Indeed, this is precisely how string theory recovers massless particles. Now, whether said massless particle is a photon or not depends on some other internal properties of the string itself.
ASIDE: In bosonic string theory, it is possible to have a string with NO EXCITATIONS, in which case $E=0$. One then recovers a particle with imaginary mass called the tachyon. Existence of such tachyons is problematic in any theory, as it leads to instabilities. This problem is solved in superstrings, where certain constraints does not allow one to have strings with no excitations.