For any number $$m \equiv 0,1 \, (4)$$ , we correct the generating function of Hurwitz class number sums $$\sum _r H(4n - mr^2)$$ to a modular form (or quasimodular form if m is a square) of weight two for the Weil representation attached to a binary quadratic form of discriminant m and determine its behavior in the Petersson scalar product. This modular form arises through holomorphic projection of the zero-value of a nonholomorphic Jacobi Eisenstein series of index 1 / m. When m is prime, we recover the classical Hirzebruch–Zagier series whose coefficients are intersection numbers of curves on a Hilbert modular surface. Finally, we calculate certain sums over class numbers by comparing coefficients with an Eisenstein series.