Using a variational procedure, the depression of the superconducting transition temperature by a system of correlated moving spins is calculated. In particular, corrections to the Abrikosov-Gorkov theory in the neighbourhood of a magnetic phase transition are examined. Characteristic differences in the concentration dependence of the superconducting transition temperature are found in the cases of ferromagnetic and antiferromagnetic spin correlations.