Let $f:\mathbb{R}\longrightarrow \mathbb{R}$ differentiable and convex first. For every $x> y$ and every $t\neq 0$, convexity yields
$$
f(tx+(1-t)y)\leq tf(x)+(1-t)f(y)\quad\Leftrightarrow\quad f(y+t(x-y))-f(y)\leq t(f(x)-f(y).
$$
So
$$
\frac{ f(y+t((x-y))-f(y)}{t(x-y)}\leq \frac{f(x)-f(y)}{x-y}
$$
for all $t\neq 0$. Letting $t$ tend to $0$, this entails
$$
f'(y)\leq \frac{f(x)-f(y)}{x-y}\quad\Leftrightarrow\quad f(x)-f(y)\geq f'(y)(x-y).
$$
for all $x>y$. In the case $x<y$, one follows the same steps reversing the inequality twice.
Now in the general case, fix $x\neq y$ and consider the function $g:\mathbb{R}\longrightarrow\mathbb{R}$
$$
g:t\longmapsto f(y+t(x-y)).
$$
Then $g$ is convex (check) and differentiable so in particular
$$
g(1)-g(0)\geq g'(0)(1-0)=g'(0).
$$
Now by the chain rule
$$
g'(t)=\nabla f(y+t(x-y))(x-y)\quad\Rightarrow \quad g'(0)=\nabla f(y)(x-y).
$$
And $g(1)=f(x)$, $g(0)=f(y)$, so
$$
f(x)-f(y)\geq \nabla f(y)(x-y).
$$