Let $m > 2$ be an integer such that $S_m(m) = \sum_{n=1}^{m-1} n^m\equiv 1 \pmod{m}$$S_m(m) = \sum_{n=1}^{m-1} n^m\equiv 1 \bmod{m}$. (Taking away $m^m$ does not harm the question, of course). Then $S_m(m)$ has the following expression in terms of Bernoulli numbers: \begin{equation*} S_m(m) = \sum_{k=0}^{m}\binom{m}{k}B_{m-k}\frac{m^{k+1}}{k+1} = B_m \cdot m + B_{m-1} \frac{m^2}{2} + \binom{m}{2} B_{m-2} \frac{m^3}{3} + \cdots \end{equation*} By the theorem of Clausen and von Staudt, the denominator of $B_k$ is the product of all primes $p$ such that $p-1$ divides $k$. In particular, they are square-free and hence we have the last displayed term and all that follow are conruent to $0$ modulo $m$. If the term $B_{m-1} \frac{m^2}{2}$ were not congruent to $0$ by the same argument, then $m$ would be even. But then $B_{m-1}=0$ unless $m=2$.
So $S_m(m) \equiv B_m \cdot m\pmod{m}$$S_m(m) \equiv B_m \cdot m\bmod{m}$. It is now clear that $m$ must be square -free as otherwise $S_m(m) \not\equiv 1\pmod{m}$$S_m(m) \not\equiv 1\bmod{m}$. Let $p$ be a prime dividing $m$. If now $B_m\cdot m$ is $p$-integral, then $p-1$ must divide $m$. Now look at the answer to the question about the "wrong little Fermat". One derives that $m$ has to be in the list $\{1,2,6,42,1806\}$ just as before. Then one checks by hand that it is true for these integers.