Conditions for the summation theorem for functions with infinitely many poles It is widely know the summation theorem via residues:
Suppose $f(z)$ analytic on $\mathbb{C}$ except for a finite number of poles. And let $f(z)$ be such that along the path $C_{N}$, the square with vertices at $\left(N+\frac{1}{2}\right)(-1+i), \left(N+\frac{1}{2}\right)(-1-i), \left(N+\frac{1}{2}\right)(1-i), \left(N+\frac{1}{2}\right)(1+i)$.
$$|f(z)|\leq\frac{M}{|z|^k}$$
where $k>1$ and $M$ are constants independent of $N$ we have
$$\sum_{n=-\infty}^{\infty} f(n) = -\sum \left\{\textrm{ residues of } \pi\cot(\pi z)f(z) \textrm{ at the poles of } f(z) \right\}$$
We can extend this theorem for functions with infinitely many poles:
Consider the path $C_{N}$. Let $f(z)$ with infinitely many poles with the conditions:
$$|f(z) |\leq \frac{M}{|z|^{k}} \tag{*}$$
along the path $C_{N}$ where $k>1$ and $M$ are constants independent of $N$
and
$$\lim_{N \to \infty} \sum_{a\in A_{N}} \operatorname{Res}\left(\pi\cot(\pi z)f(z),a\right)<\infty$$
where
$$A_{N} = \left\{ \textrm{poles of } f(z) \textrm{ inside } C_{N} \right\}$$
then:
$$\sum_{n=-\infty}^{\infty} f(n) = \lim_{N \to \infty} \sum_{a\in A_{N}} \operatorname{Res}\left(\pi\cot(\pi z)f(z),a\right)$$
the set of $C_{N}$ is called "Big squares".

*

*Can we weaken the condition $(*)$? For example, $f(z)$ to be $\mathcal{O}(z^{-2})$ at infinity?

$$|f(z)| \leq \frac{M}{|z|^{2}} \quad z \to \infty$$
or there are even weaker conditions?


*What is a good reference for the summation theorem for functions with infinitely many poles?

Here is my try for question 1:
Given that $f(z)$ is $\mathcal{O}(z^{-2})$ :
$\exists \delta,M>0$ so that whenever $|z|>\delta$
$$|f(z)|\leq\frac{M}{|z|^2}$$
If we choose our first square $C_{N}$ for $N$ sufficiently large such that $|z|>\delta$ then
$$\oint_{C_{N}} \pi \cot(\pi z)f(z) dz = \sum_{n=-N}^{N} f(n) + \sum_{a\in A_{N}} \operatorname{Res}\left(\pi\cot(\pi z)f(z),a\right)
$$
We just have to prove that
$$\oint_{C_{N}} \pi \cot(\pi z)f(z) dz  \to 0 \quad N \to \infty$$
But it can be proven that
$$|\cot(\pi z)|$$ is bounded in $C_{N}$:
$$|\cot(\pi z)|\leq A$$
Then
$$\left| \oint_{C_{N}} \pi \cot(\pi z) f(z) dz\right| \leq \frac{\pi A M}{N^2}(8N+4)$$
since the lenght of the path $C_{N}$ is $8N+4$.
Hence, the integral vanishes as $N \to \infty$.
 A: Your proof is fine if $f(z)$ is a meromorphic function on $\mathbb{C}$ with a finite number of poles.
The issue is if meromorphic functions with infinitely many poles can even be  $O(z^{-2})$ as $|z| \to \infty$ since if would require that the poles of the function are all located inside a circle of finite radius.
Something close is $\psi^{(2)}(z)$ (i.e., the second derivative of the digamma function).  It's $O(z^{-2})$, but that's only if you stay away from the negative real axis.  The reason for that is $\psi^{(2)}(z)$ has triple poles at all the negative integers.  If complex infinity is approached in a continuous manner along the negative real axis, $\psi^{(2)}(z) $ will keep becoming arbitrarily large near every negative integer.
So if you wanted to argue that $\lim_{N \to \infty} \oint_{C_{N}} \pi \cot(\pi z) \psi^{(2)}(z) \, \mathrm dz$ vanishes as $N \to \infty$ through the positive integers, you would need to argue that $\psi_{2}(z)$ is  also $O(z^{-2})$ on the part of the contour that passes halfway between two negative integers.
(See the comments under this answer for a related discussion about the digamma function. Go all the way to the end.)
This is also not a great example because the summation theorem assumes that $f(z)$ doesn't have poles at the integers.

EDIT:
If a meromorphic function with infinitely many poles had all its poles inside a circle of finite radius, they would have to be spaced in such a way that they don't accumulate near a point (which would result in the function having a non-isolated singularity at that point). This is not possible.
SECOND EDIT:
The related theorem for alternating infinite sums holds if $f(z)$ is $O(z^{-1})$ as $|z| \to \infty$ because in addition to $\csc(\pi z)$ being uniformly bounded on $C_{N}$, the magnitude of $\csc(\pi z)$ tends to zero exponentially fast as $\Im(z) \to \pm \infty$.
The alternating summation theorem also holds for a function like $\operatorname{csch}^{2}(\pi z)$ because it's uniformly bounded on $C_{N}$, and its magnitude tends to zero exponentially fast as $\Re(z) \to \pm \infty$.
THIRD EDIT:
I should also mention that if you use the modified kernel $\pi \left(\cot(\pi z))-i \right) = \pi e^{-i \pi z} \csc(\pi z)$, then the summation formula holds for functions of the form $e^{iaz} f(z)$, where $f(z)$ is $O(z^{-1})$ as $|z| \to \infty$ and $0 < a < 2 \pi$.
