In religious teachings, one of the things man has been advised against in order to protect him from sin, is to be alone with a non-mahram.
In his advice to Prophet Musa (AS), Satan says: “O Musa, never be alone with a non-mahram woman, for whoever does so, I personally will be his friend, not my friends.”
Also, he says to Prophet Nuh (AS): “Whenever you are alone with a non-mahram woman and there is no one else around, remember me.”
Therefore, since Satan is with the individual when he is alone with a non-mahram woman, one must refrain from such, in order not to become subject to Satan’s temptations.
The point that is necessary to be mentioned here is that sometimes, it is might be necessary to be alone with a non-mahram for certain purposes, such as studying or consultation. In such cases, keeping in mind and observing religious boundaries, one can take care of this business in public places so that Satan can't take advantage and lead one to wrong.
It is also noteworthy that, although Satan is man’s clear enemy, and in many cases we mustn’t listen to him, but when it comes to wise words, we must heed to them, even if it is our enemy who is saying them, as Imam Ali (AS) says:
1. “Learn wisdom even if it is a polytheist saying it.”
2. “Don’t look at the speaker, but look at the speech”, meaning that true words must be taken from anyone, regardless of who is saying them.
3. “Knowledge and wisdom is the long lost treasure of the believers that they are looking for; seek it even from the polytheist.”
1. Legitimate sexual relationship between a boy and girl, Question 20507 (site: 19736).
2. Islam and sound relationship between boys and girls, Question 1044 (site: 1110).
 Mufid, Muhammad ibn Muhammad, al-Amaali, pg. 157, The Sheikh Mufid Assembly, Qum, 1413 AH.
 Shaykh Saduq, Khisaal, vol. 1, pg. 132, Jame’eye Mudarrisin Press, Qum 1403 AH.
 Abul-Fadhl, Ali ibn Hasan, Tabarsi, Mishkaat al-Anwaar, pg. 135, Haydariyyah Library, Najaf, 1385 AH.
 Tamimi Aamidi, Abd al-Wahid, Ghurar al-Hikam, hadith 612, pg. 58, Islamic Propagation Office Press, Qum, 1977.
 Shaykh Tusi, al-Amaali, pg. 625, Daar al-Thaqaafah Press, Qum, 1414 AH.