A new algorithm is developed for computing e(tA)B, where A is an n x n matrix and B is n x n(0) with n(0) << n. The algorithm works for any A, its computational cost is dominated by the formation of products of A with n x n0 matrices, and the only input parameter is a backward error tolerance. The algorithm can return a single matrix e(tA)B or a sequence e(t)k(A)B on an equally spaced grid of points t(k). It uses the scaling part of the scaling and squaring method together with a truncated Taylor series approximation to the exponential. It determines the amount of scaling and the Taylor degree using the recent analysis of Al-Mohy and Higham [SIAM J. Matrix Anal. Appl., 31 (2009), pp. 970-989], which provides sharp truncation error bounds expressed in terms of the quantities parallel to A(k)parallel to(1/k) for a few values of k, where the norms are estimated using a matrix norm estimator. Shifting and balancing are used as preprocessing steps to reduce the cost of the algorithm. Numerical experiments show that the algorithm performs in a numerically stable fashion across a wide range of problems, and analysis of rounding errors and of the conditioning of the problem provides theoretical support. Experimental comparisons with MATLAB codes based on Krylov subspace, Chebyshev polynomial, and Laguerre polynomial methods show the new algorithm to be sometimes much superior in terms of computational cost and accuracy. An important application of the algorithm is to exponential integrators for ordinary differential equations. It is shown that the sums of the form Sigma(p)(k=0) phi(k)(A)u(k) that arise in exponential integrators, where the phi k are related to the exponential function, can be expressed in terms of a single exponential of a matrix of dimension n + p built by augmenting A with additional rows and columns, and the algorithm of this paper can therefore be employed.