The telegraph equation is one of the important equations of mathematical physics. In this work, a spectral collocation scheme is proposed for the numerical solutions of one- and two-dimensional linear telegraph equations and telegraph equations with nonlinear forcing term. The homogeneous initial and boundary conditions are satisfied exactly by expanding the unknown variable using polynomial bases of functions which are built upon the Jacobi polynomials. The suggested scheme is successfully developed for the aforementioned problem with nonhomogeneous data. Extensive numerical experiments are presented to verify the efficiency of the proposed scheme.