A mayor in one of the nation’s whitest states resigned in disgrace after a series of racist text messages he sent were made public.