Whenever a man is alone with a woman the Devil makes a third.
Hadith – Al-Tirmidhi.
Do not call on women in the absence of their husbands, because Shaitan might be circulating in you like blood circulates
Hadith – Fath-al-Qadir
The one who touches the hand of a woman without having a lawful relation with her, will have an ember (hot coal) placed on his palm on the Day of Judgement
If you cannot meet a woman without mahram, shake hands with her, be alone with her, look at her (since you’re required to lower your gaze)
then how is this friendship going to form?
As far as friendship on internet is concerned just reason logically about it. Would a husband appreciate that his wife has a ‘close’ male friend besides him? Or would a wife appreciate that when the husband has a argument with her, he goes to his best friend to discuss the matter as opposed to making it up to her?
It leads to comparison between spouse as a friend and the close friend. This can cause problems in their married life. A friend who meets you only sometimes will always meet you with a smile (even on internet) but the spouse is living with you 24/7. There are more chances of conflicts and it requires patience and understanding to survive the relationship.
This can be hard to understand when you can see the other opposite gender being nice to you while your spouse isn’t as sweet most of the time.
Had it been permissible Sahaba’s and Prophets would become friends with women. But at least I do not know of Prophet (P.B.U.H) having female friends or any of the sahaba’s having them or any other scholar of Islam having it. Which makes it obvious it is not allowed in Islam.