Let $\mathfrak{g}$ be solvable Lie algebra. Lie’s theorem states, that adjoint representation is a homomorphism $\operatorname{ad}:\mathfrak{g}\to \mathfrak{t}$, where $\mathfrak{t}$ is an algebra of upper-triangular matrices. Let $\mathfrak{d}\subset\mathfrak{t}$ be a subalgebra of diagonal matrices.
Is it true, that $\mathfrak{g}$ is nilpotent iff $\operatorname{ad}^{-1}(\mathfrak{d})=Z(\mathfrak{g})$? In one direction it is exactly the Engel’s theorem, but I cannot find counter examples or proof for the other direction.
UPD I want to rephrase my question in an equivalent way. Is it true, that all solvable, but not nilpotent subalgebras of upper-triangular algebra contain nonzero diagonal elements?
Consider the non commutative algebra of dimension $2$ generated by $x,y$ defined by $[x,y]=x$.
The matrix of $ad_x$ in the basis $(x,y)$ is $\pmatrix{0&1\cr 0&0}$ the matrix of $ad_y$ is $\pmatrix{-1&0\cr 0&0}$. $ad_y$ is diagonal, but this Lie algebra is solvable and not nilpotent and $y$ is not in the center.