I encounter a problem when computing the following integral in two ways $$ \frac{1}{2\pi i}\int_\gamma \frac{e^{s^2}}{s\cosh(\pi As)}ds$$ where $\gamma$ is contour defined by the rectangle $[-1,1]\times[-K,K]$, $AK\in\mathbb{N}$ and $A>0$.
On the one hand, the poles are $0$ and $iA^{-1}(k+1/2)$ with $k$ integer with residue (respectively) $1$ and $(-1)^{k+1}i\pi^{-1} e^{-(k+1/2)A^{-1}}(k+1/2)^{-1}$. The real part of the integral must the be $1$.
On the other hand, one can bound directly the integral. For the vertical lines (for instance $\Re(s) = 1$), one gets
$$\frac{1}{2\pi}\int_{-K}^K \frac{e^{(1+it)^2}}{(1+it)\cosh(\pi A(1+it))}dt\ll e^{-\pi A}$$ with the constant independant of $K$. For the horizontal lines, one has $$\cosh(\pi A(x+iK))^{-1}\leq 2 $$ so the integrals are bounded by $O(e^{-K^2})$ with constant independant on $A$.
In the end, after applying the residue theorem, I get
$$1-i\pi^{-1}\sum_{{|k+1/2|<K}} (-1)^{k}e^{-((k+1/2)A^{-1})^2}(k+1/2)^{-1} =O(e^{-\pi A}+e^{-K^2})$$.
Now taking the real part and $K\to \infty$ (everything is converging), I get a contradiction of the type $1 \ll e^{-A}$ which is stupid since $A$ can be as big as we want.
I don't seem to find my mistake and any help would be welcome.
EDIT:
To be clear I will write how I get the estimates for the bounds on the vertical lines.
First we have $\cosh(A\pi(\pm 1+it))^{-1}< 2e^{-\pi A}$ uniformly in $t$. This gives $$ \left|\frac{1}{2\pi}\int_{-K}^K \frac{e^{(\pm 1+it)^2}}{(\pm 1+it)\cosh(\pi A(\pm 1+it))}dt\right|< 2e^{-\pi A}\frac{1}{2\pi}\int_{-K}^K \frac{e^{1-t^2}}{\sqrt{1+t^2}}dt<Ce^{-\pi A}$$ where $$ C = \pi^{-1}\int_{-\infty}^\infty \frac{e^{1-t^2}}{\sqrt{1+t^2}}dt.$$
EDIT 2:
For the horizontal lines, let us use the fact that, for $-1\leq\sigma\leq 1$, one has $|\cosh(\pi A \sigma \pm i\pi AK)| = |\cosh(\pi A \sigma)|\geq1$ since $AK$ was chosen to be an integer. This gives
$$\left|\frac{1}{2\pi i}\int_{-1}^1\frac{e^{\sigma^2-K^2}}{(\sigma\pm iK)\cosh(\pi A(\sigma\pm iK))}d\sigma\right|\leq (2\pi K)^{-1}e^{-K^2}\int_{-1}^1e^{\sigma^2}d\sigma.$$
Clearly, when $K$ gets big this goes to $0$.
You have miscomputed the residues. For $k \in \mathbb{Z}$, let $$s_k = i\frac{k + \frac{1}{2}}{A} = i\cdot t_k\,.$$ Then $$\operatorname{Res} \biggl(\frac{e^{s^2}}{s\cosh (\pi As)}; s_k\biggr) = \frac{e^{s_k^2}}{s_k \pi A\sinh (\pi A s_k)} = -\frac{e^{-t_k^2}}{t_k\pi A\sin(\pi A t_k)} = (-1)^{k+1} \frac{\exp\bigl(-(k + 1/2)^2/A^2\bigr)}{\pi\bigl(k + \frac{1}{2}\bigr)}$$ since $\sinh (iw) = i\sin w$.
Hence all residues are real and your estimate shows $$1 - \frac{2}{\pi}\sum_{k = -\infty}^{+\infty} (-1)^k \frac{\exp\bigl(-(k + 1/2)^2/A^2\bigr)}{2k+1} \ll e^{-\pi A}\,.$$ This is credible, replacing the exponential in the numerator by $1$ (corresponding to "$A = +\infty$") makes the left hand side vanish.