[Tex/LaTex] LaTeX letter: undefined control sequence on \opening command

letters

I'm trying to use the \opening{} command in a LaTeX letter but getting an undefined control sequence error on it for some obscure reason.

Minimal working example:

\documentclass[11pt]{letter}
\begin{document}

Dear John,

%Letter goes here

\end{document}

And minimal not-working example:

\documentclass[11pt]{letter}
\begin{document}

\opening{Dear John,}

%Letter goes here

\end{document}

Note that for some reason the \closing{} command (not included above) works just fine. I'm using TexMaker and compiling with PdfLaTeX (but LaTeX + dvips + ps2pdf doesn't work any better).

Any clue what's going on?

Best Answer

Many thanks to egreg for the quick answer, which is that the letter needs to be enclosed in a \begin{letter} … \end{letter} block, that I stupidly missed. Here's the working code:

\documentclass[11pt]{letter}

\begin{document}

\begin{letter}{}
\opening{Dear Johnny,}

%Letter goes here

\end{letter}
\end{document}
Related Question