Here's an elementary example. For any field $k$, consider the ring $k[t^q|q\in\mathbb Q_{>0}]$, which I'll abbreviate $k[t^q]$. I claim that the natural quotient $k[t^q]\to k$ given by sending $t^q$ to $0$ is formally smooth but *not flat*, and therefore not smooth.

First let's show it's formally smooth. Let $A$ be a ring with square-zero ideal $I\subseteq A$, and suppose we have maps $f:k[t^q]\to A$ and $g:k\to A/I$ making the following square commute (I drew it backwards because you're probably thinking of Spec of everything)

$$
\begin{array}{ccc}
A/I & \xleftarrow g & k \\
\uparrow & & \uparrow\\
A & \xleftarrow f & k[t^q]
\end{array}
$$

We'd like to show that there's a map $k\to A$ filling the diagram in. For any $q\in \mathbb Q_{>0}$, note that $f(t^q)\in I$ by commutativity of the square, so $f(t^{2q})\in I^2=0$. But every $q$ is of the form $2q'$ for some $q'$, so we've shown that $f(t^q)=0$ for all $q\in \mathbb Q_{>0}$. So $f$ factors through $k$, as desired.

Now let's show that $k$ is not flat over $k[t^q]$. Consider the exact sequence
$$0\to (t)\to k[t^q]\to k[t^q]/(t)\to 0.$$
When you tensor with $k$, you get
$$0\to k\to k\to k\to 0,$$
which is obviously not exact. So $k$ is not flat over $k[t^q]$.