I started learning a bit ahead from an old physics book, and they were discussing the photoelectric effect and after that Planck's hypotheses and energy quantas.
The book said that the mass of a microscopic oscillator (what is that?) is not continuous, but discrete and the difference between states is an energy quanta:
$ \varepsilon = h\nu = E_k - E_i $
And since $ E = mc^2 $ then the (relativistic) mass of the photon is
$ m = \frac{h\nu}{c^2} $
How did they deduce that?