For what kind of matrix $A$, there is a (symmetric) positive definite matrix $B$ such that $BA$ is symmetric

Let $$A$$ be a $$n\times n$$ real matrix. My ultimate goal is to find a sufficient condition on $$A$$ such that all the eigenvalues of $$A$$ are real.

Therefore, I want $$A$$ to be self-adjoint with respect to some inner-product. A general inner product associated with a positive definite matrix $$B$$ is given by $$=x^tBy$$. Then $$A$$ is self-adjoint if $$A^tB=BA$$, i.e. $$BA$$ is symmetric.

So my problem reduces to "for what kind of matrix $$A$$, there is a (symmetric) positive definite matrix $$B$$ such that $$BA$$ is symmetric".

My idea: Given $$A$$, we want to find a positive definite $$n\times n$$ matrix $$B$$ by solving the equation $$A^tB=BA$$. There are $$\frac{n(n+1)}{2}$$ variables (not $$n^2$$) as $$B$$ is symmetric. There are $$n^2$$ equations but it seems that only $$\frac{n(n-1)}{2}$$ of them are independent. Therefore, the solutions should be abundant as there are more variables than equations. However, I don't know how to make sure the solution is positive definite. It is possible that the solution space does not intersect with the positive cone of positive definite matrices, except at $$0$$.

Indeed, such a matrix $$B$$ exists if and only if $$A$$ has a real spectrum.
If $$A$$ has a real spectrum, then $$A=P^{-1}DP$$ for some real matrix $$P$$ and diagonal matrix $$D$$. Therefore, $$B:=P^TP$$ is positive definite and $$BA=P^TDP$$ is symmetric.
Conversely, suppose $$S:=BA$$ is symmetric for some positive definite $$B$$. Then $$A=B^{-1}S$$ is similar to $$B^{-1/2}SB^{-1/2}$$ and hence it has a real spectrum.