Sahih al-Bukhari Book 67, Hadith 171
The Prophet (ﷺ) said, "If the wife of anyone of you asks permission to go to the mosque, he should not
forbid her."
Once Sa`da bint Zam`a went out at night for some need, and `Umar saw her, and recognizing her, he said (to her), "By Allah, O Sa`da! You cannot hide yourself from us." So she returned to the Prophet (ﷺ) and mentioned that to him while he was sitting in my dwelling taking his supper and holding a bone covered with meat in his hand. Then the Divine Inspiration was revealed to him and when that state was over, he (the Prophet (ﷺ) was saying: "O women! You have been allowed by Allah to go out for your needs."
My foster uncle came and asked permission (to enter) but I refused to admit him till I asked Allah's Apostle about that. He said, "He is your uncle, so allow him to come in." I said, "O Allah's Messenger (ﷺ)! I have been suckled by a woman and not by a man." Allah's Messenger (ﷺ) said, "He is your uncle, so let him enter upon you." And that happened after the order of Al-Hijab (compulsory veiling) was revealed. All things which become unlawful because of blood relations are unlawful because of the corresponding foster suckling relations.