Goin’ South (1978)

Henry Moon is captured for a capital offense by a posse when his horse quits while trying to escape to Mexico. He finds that there is a post-Civil War law in the small town that any single or widowed woman can save him from the gallows by marrying him.