Sahih Muslim, Book 16, Hadith 12 (Muslim 3378)

Jabir heard Allah's Apostle (ﷺ) say:

When a woman fascinates any one of you and she captivates his heart, he should go to his wife and have an intercourse with her, for it would repel what he feels.