I'm using the addtotoc option from includepdf to add a TOC entry for two included PDFs. However, the table of contents always thinks they're on the first page (note that I have rebuilt the document enough times for the aux files to be read properly). Other similar answers on this site seem to suggest using addtotoc, but I'm already doing that (and have the same result if adding the contents line manually as shown in the example).

In this case I expect each document title to show up as an entry in the ToC at the correct page (eg. pages 1 and 220 or so in this specific example):

\documentclass[letterpaper]{book}

\usepackage{pdfpages}
\usepackage{titling}

\setcounter{secnumdepth}{-1}

% Has the same result as using the addtotoc option

\newcommand{\includerfc}[4]{
\cleardoublepage
\title{#1}
\author{#2}
\date{#3}
\maketitle
\cleardoublepage
}

\begin{document}

\frontmatter
\tableofcontents
\mainmatter

\includerfc{Extensible Messaging and Presence Protocol: Core}{P. Saint‐Andre}{March 2011}{6120}
\includerfc{Use of Transport Layer Security in the\\*Extensible Messaging and Presence Protocol}{P. Saint‐Andre\\T. Alkemade}{June 2015}{7590}
\end{document}


Is there something I can do to ensure that the page number is the actual page in the output PDF or isn't read until the external PDFs have been inserted?

The PDFs used in this example document are:

• Difficult to compile this is, link to the .pdf files give you must ;-)
– user31729
Jul 11 '16 at 19:44
• EDIT: Links added in the original question. Thanks! Jul 11 '16 at 19:45

TL;DR — \maketitle was resetting the page numbers.
It turned out that when I commented out the \maketitle, everything worked fine. This led me to dig into the titlepage package so I started commenting out things there. Eventually I noticed that it worked when I got rid of the titlepage environment, so I dug into that and found it in the book class.
Turns out that the title page resets the line numbering (as you might expect since it should be the first page), and using the titling environment to insert multiple title pages does not change this behavior or give you a way to configure it (as far as I can see).