Repost from an older answer.
Let $R$ be a commutative ring and $f\in R[X]$. Then $f$ is a zerodivisor if and only if there exists $a\in R$, $a\neq 0$ such that $af=0$.
Let $f=a_0+a_1X+\dots +a_nX^n$ with $a_n\neq 0$. If $f$ is a zerodivizor, then there exists $g\in R[X]$, $g\neq 0$ with $fg=0$. Choose $g$ of minimal degree with this property. Set $g(X)=b_0+b_1X+\cdots+b_mX^m$, $b_m\neq 0$. From $fg=0$ it follows that $a_nb_m=0$. Then the degree of $a_ng$ is less than $m$, $(a_ng)f=0$, and thus $a_ng=0$. In particular, $a_nb_{m-1}=0$ and looking at the coefficient of $X^{m+n-1}$ in $fg$ we get that $a_{n-1}b_m=0$. Then the degree of $a_{n-1}g$ is less than $m$, $(a_{n-1}g)f=0$, and therefore $a_{n-1}g=0$. Similar arguments show that $a_ig=0$
for all $0\leq i\leq n$. This implies $a_ib_m=0$ for all $i$, so $b_mf=0$, qed.