In Über die Bestimmung asymptotischer Gesetze in der
Zahlentheorie, Dirichlet proved his theorem on the asymptotic
behaviour of the divisor function using a Lambert series: let
$d_n = d(n)$ denote the number of the divisors of $n$; then
Lambert (actually this is due to Euler) observed that
$$ f(z) = \sum_{n=1}^\infty d_n z^n
= \sum_{n=1}^\infty \frac{z^n}{1-z^n} . $$
This series converges for $|z| < 1$, and diverges for $z = 1$.
Setting $z = e^{-t}$ we obtain
$$ g(t) = \sum_{n=1}^\infty \frac{e^{-nt}}{1-e^{-nt}}
= \sum_{n=1}^\infty \frac{1}{e^{nt}-1} . $$
Dirichlet writes that "expressing this series by a definite integral one easily finds" that $$ g(t) \sim \frac1t \log \frac1t + \frac{\gamma}t $$ as $t \to 0$, where $\gamma$ is Euler's constant.
Dirichlet then claims that the asymptotic behaviour of $g(t)$ would imply that $d_n$ is, on the average, equal to $\log n + 2 \gamma$, which in turn implies that $b_1 + b_2 + \ldots + b_n \approx (n + \frac12) \log n + (2\gamma+1)n. $ He mentions that he has used the integral expressions for $\Gamma(k)$ and its derivative $\Gamma'(k)$ for deriving the first property.
Knopp (Über Lambertsche Reihen, J. Reine Angew. Math. 142) claims that Dirichlet's proof was "heuristic". I find that hard to believe, and I am convinced that Dirichlet's sketch can be turned into a valid proof by someone who knows the tools of the trade. So here are my questions:
How did Dirichlet express "this series by a definite integral" and derive the asymptotic expression for $g(t)$?
Let me remark that Endres and Steiner (A new proof of the Voronoi summation formula) use Voronoi summation for proving the sharper estimate $$ g(t) \sim \frac1t \log \frac1t + \frac{\gamma}t + \frac14 + O(t) $$ as $t \to 0$. But this is not "easily found".
How did Dirichlet transform his knowledge about the asymptotic behaviour of $\sum b_n e^{-nt}$ as $t \to 0$ into an average behaviour of $b_n$? This smells like a Tauberian result, but I'm not fluent enough in analytic number theory to see how easy this is.