Author's affiliation at the end of the article with the article class

I'm looking for a good way how to put the affiliation on the last page after all the text, using the document class article. For instance, in the document class amsart this option is realized by default.

The minimal working example for the document class article is the following:

\documentclass{article}
\usepackage{authblk}

\title{The title}

\author{Author A\thanks{email@Author.A}}

\usepackage{lipsum}
\begin{document}
\maketitle
\lipsum[1]
\end{document}


And it produces something like that:

The minimal working example for the document class amsart is the following:

\documentclass{amsart}

\title{The title}

\author{Author A}
\email{email@Author.A}

\usepackage{lipsum}
\begin{document}
\maketitle
\lipsum[1]
\end{document}


And it produce something that looks like I want to:

Here's a slightly different way to do it:

\documentclass{article}
\usepackage{url}
\makeatletter
\newcommand{\email}[1]{\gdef\@email{\url{#1}}}
\newcommand{\@endstuff}{\par\vspace{\baselineskip}\noindent\small
\AtEndDocument{\@endstuff}
\makeatother
\title{A title}
\author{Author A}
\email{email@Author.A}
\usepackage{lipsum}
\begin{document}
\maketitle
\lipsum[1]
\end{document}


• While I was playing a bit with my answer, I asked myself, why I didn't use \AtEndDocument... – Skillmon likes topanswers.xyz Jan 29 '18 at 23:16

If typesetting it manually is ok for you, you can use:

\documentclass{article}
\usepackage{authblk}

\AtEndDocument{%
\par
\medskip
\begin{tabular}{@{}l@{}}%
\end{tabular}}

\title{The title}

\author{Author A\thanks{email@Author.A}}

\usepackage{lipsum}
\begin{document}
\maketitle
\lipsum[1]
\end{document}


If it should be more automated, the following allows you to use an arbitrary number of authors. The macro \print@author controls what should be printed for a single author.

\documentclass{article}
\usepackage{etoolbox}
\usepackage{hyperref}

\makeatletter
\newcounter{author}
\renewcommand*\author[1]{%
\stepcounter{author}%
\ifnum\c@author=1
\gdef\@author{#1}%
\else
\xdef\@author{\unexpanded\expandafter{\@author\and#1}}%
\fi
\csgdef{author@\the\c@author}{#1}}
\newcommand*\email[1]{%
\csgdef{email@\the\c@author}{#1}}
\AtEndDocument{%
\xdef\author@count{\the\c@author}%
\c@author=1
\print@authors}
\newcommand*\print@authors{%
\ifnum\c@author>\author@count
\else
\print@author{\the\c@author}%
\expandafter\print@authors
\fi}
\newcommand*\print@author[1]{%
\par\medskip
\begin{tabular}{@{}l@{}}%
\href{mailto:\csuse{email@#1}}{\csuse{email@#1}}
\end{tabular}}
\makeatother

\title{The title}

\author{Author A}
\email{email@Author.A}

\author{Author B}