A simple and effective numerical method is proposed for simulating the temporal diffusive mass transport process through a microstructure with arbitrary complexity described by a phase-field approach. The mass diffusion through a given microstructure is modeled by a diffusion equation with a variable diffusion coefficient, which is solved by an efficient and accurate semi-implicit spectral method. It is shown that it is possible to extract the effective diffusion coefficient for any given microstructure from the temporal concentration profiles. The method is used to simulate the grain boundary diffusion in a single-phase polycrystalline grain structure and the heterogeneous diffusion in a two-phase microstructure with different diffusion coefficient in each phase. Results are compared with existing analytical theories and computer simulations.