Behold, no person should spend the night with a married woman, but only in case he is married to her or he is her Mahram. (Using translation from Muslim 2171)
قَالَ رَسُولُ اللهِ ﷺ «أَلَا لَا يَبِيتَنَّ رَجُلٌ عِنْدَ امْرَأَةٍ إِلَّا أَنْ يَكُونَ نَاكِحًا أَوْ ذَا مَحْرَمٍ»