We report a theoretical investigation of the resonant donor magnetopolaron in GaAs. The energy levels of the ground state (1s-like) and eight excited states (2s-, 2p+/--, 2pz-, 3d+/-2-, 4f+/-3-like) of the donor have been obtained as a function of the magnetic-field strength (B). The calculation is based on a variational approach in which we use a trial wave function with two variational parameters for all states but three for the 2s state. This approach gives (1) the exact energy values in the limits of B=0, and (2) the energy levels that are very close to known more exact calculations at high magnetic fields. The magnetopolaron effect on these energies is studied within second-order perturbation theory. In order to explain the available experimental results it is sufficient to take into account the seven lowest donor states (1s, 2s, 2p+/-, 2pz, 3d-2, 4f-3) and to include band nonparabolicity. Our results are in very good agreement with the available experimental data.