Both 부인(夫人) and 사모님(師母님) are respectful terms used to refer to another man's wife, but while 부인 can be used to refer respectfully to any other man's wife, 사모님 was originally used to refer respectfully to the wife of a teacher or mentor.
부인(夫人) literally means "a husband's (夫) person (人)" or "a man's (夫) person (人)," but even though the literal meaning sounds more like the description of a servant than a wife, 부인 is still considered to be a polite reference to another man's wife. If you wanted to be really polite, you could say 영부인 (令夫人), which could translate as "beautiful (영) wife (夫人)," "good (令) wife (夫人)," or "esteemed (令) wife (夫人)."
Besides meaning "to command" or "to order," 令 (령) can, strangely, also mean "beautiful" or "good." It can also be used as an "honorific title," which is why 영부인 (令夫人) could also be translated as "esteemed (令) wife (夫人)." Even though Koreans seem to use 영부인 more to refer to the wife of a president, there is no reason it cannot be used to refer to the wife of any person you respect. In other words, using 영부인 to refer to a Korean friend's wife may get a smile from your friend and an embarrassed giggle from his wife, but both would still likely appreciate the polite gesture.
As for 사모님 (師母님), even though it literally means "teacher's (師) mother (母)," it was originally used to refer respectfully to the wife of a person's teacher or mentor. Because a teacher is highly regarded in Korean society, 사모님 is generally considered to be more polite than 부인, but 부인 is still considered to be a polite reference. Generally, a teacher or mentor is an older person, so 사모님 can be used to refer to an older friend's wife, but it would probably sound strange if used to refer to a younger friend's wife. In other words, 부인 can be politely used with anyone, but 사모님 should be used only to refer to the wife of an older person or friend, especially if that person or friend is your teacher or mentor.