It is an experimental fact that a photon is massless. To prove this theoretically in full generality, one requires to wade through some QFT. However, arguments for massive photons lead to a reductio ad absurdum even by just taking special relativity into consideration. The so-called relativistic mass $(m: E = mc^2 \iff \vec{p} = m\vec{v})$ of a particle of rest mass $m_0$ moving at a velocity $\vec{v}$ relative to the observer is given by,
$$
\begin{equation}
m = \frac{m_0}{\sqrt{1 - \frac{v^2}{c^2}}}
\end{equation}
$$
If we assume a photon to be massive, then $m$ ends up undefined. In the context of limits (say, $v \to c$), one could either say that the limit doesn't exist or $m \to \infty \implies E \to \infty$. None of these make much sense. However, in the same context for the massless case (say instead of $m_0 = 0$, we take $m_0 \to 0$), we end up concluding that the form for $m$ is indeterminate ($0/0$ form). This is not absurd however (unless of course the limit doesn't exist), because we simply cannot evaluate the limit in the given form. Many sources tend to describe the relativistic mass of the photon to be given by,
$$
\begin{equation}
m = \frac{E}{c^2} = \frac{h}{\lambda c}
\end{equation}
$$
as it also satisfies $p = mc$. One could perhaps think of this to be what the original limit would produce and be relieved of any nightmares. Hence one can safely conclude that for the photon, $m_0 = 0$.
EDIT: When it comes down to it, it is alright to replace $\to$ with $=$ for simple physical purposes like I did in the end. In truth ofc, this argument only tells us that $m_0 \to 0$, but that is still okay in the context of your required derivation.