There's a little bit of calculation you need to do here to make sure Cauchy's Residue Theorem is applicable here (you need to make sure that certain integrals are bounded etc) but this is a sketch:
Let
$$
f(z) = \frac {\pi} {(1+z^2)\tan(\pi z)}
$$
Then $f$ has simple poles $\forall n \in \mathbb{Z}$ and also at $\pm i$.
You can calculate the residues as
$$
\text{Res}(f(z), n\pi) = \frac {1} {1 + n^2}
$$
and
$$ \text{Res}(f(z), \pm i) = \frac {-\pi} {2tanh(\pi)}
$$
If these are hard to calculate for you, I can give you more detail.
Now, let $\Gamma _N$ be the square contour with vertices $(N + \frac 1 2) (\pm 1 \pm i)$
Then Cauchy's Residue Theorem tells us
$$
\int_{\Gamma N} f(z) dz = 2\pi i \sum \text{Res}(f(z), z)
$$
Where the sum is across all the poles inside the contour.
Now, we see that the simple poles inside the contour are all the ones at integers $n$ s.t. $|n| < N$ and the ones at $\pm i$.
So
$$
\int_{\Gamma N} f(z) dz = 2\pi i \left [ \frac {-2\pi} {2 \tanh(\pi)} + \sum_{n = -N}^{N} \frac{1} {1 + n^2} \right ]
$$
Now we need to show that the integral on the left goes to zero as $N$ tends to infinity. Now, I'm going to leave this as an exercise for you (unlucky) but the basic idea is to find a constant $C_1$ which bounds $\frac {\pi} {tan(\pi z)}$ on the top and bottom of the square and another constant $C_2$ on the sides of the square and take $C$ to be the maximum of these.
Then by the Estimation Theorem we would have that
$$
\left | \int_{\Gamma_N} f(z) dz \right | \leq \text{length}(\Gamma_N) \text{sup}_{z \in \Gamma _N} |f(z)| \leq 4(2N + 1) C \text{sup}_{z \in \Gamma_N} \left\| \frac {1} {1 + z^2}\right \| \leq \frac {4C(2N + 1)} { 1 + N^2} = O(\frac 1 N)
$$
So we let $N \to \infty$ then we get
$$
0 = 2\pi i \left [ \frac {-2\pi} {2 \tanh(\pi)} + \sum_{n = -\infty}^{\infty} \frac{1} {1 + n^2} \right ]
$$
So then we have
$$
0 = \frac {-\pi} { \tanh(\pi)} + 2\sum_{n = 1}^{\infty} \frac{1} {1 + n^2} + 1
$$
Where the 1 that has randomly appeared is the $n = 0 $ term
So
$$
\sum_{n = 1}^{\infty} \frac{1} {1 + n^2} = \frac 1 2 \left [\frac {\pi} { \tanh(\pi)} - 1 \right] = \frac 1 2 (\pi \coth (\pi) - 1).
$$
I hope you know some complex analysis otherwise this might have meant nothing to you...
This method works for most sums though (as long as you get the right things tending to zero, which you do in this case) and I don't think I've ever had it not work.
If you want to evaluate
$$ \sum_{n = 1} ^ {\infty} \phi(n)
$$
Where \phi can easily be extended to all of $\mathbb {C}$ you just take
$$f(z) = \frac {\pi} {\phi(z) \tan(\pi z)}
$$
And do the same thing, and if you want to evaluate
$$\sum_{n = 1} ^ {\infty} (-1)^n \phi(n)
$$
You just take
$$f(z) = \frac {\pi} {\phi(z) \sin(\pi z)}
$$
In each case integrating over the same contour. Hope this helps, and if you don't know much complex analysis, you should learn more, it is a very interesting and powerful area. Sorry this was the longest answer ever.