In a magnetic field, it would require the thing that passes through it to have all their electrons paired up for it to be unaffected or repulsed. And if there is an empty orbital or an unpaired electron, it’ll be attracted. Sunlight can’t have these properties, it has no charge or mass