A new spectral method for a class of linear boundary value problems