Rav Ephrayim was the head of the Beis Din of the city of Brod. Once, he himself was involved in a dispute with another Jew in the city, and both parties had to appear before the beis din to settle it. In order that there shouldn't be even the slightest suspicion that the Rabbonim of the beis din were prejudiced in their judgment toward him, Rav Ephrayim agreed to travel with the other party to a distant city where no one knew him.
One evening, on their way to that city, they stopped at an inn in a small village. The Baal Shem Tov, who was then a melamed for the young children there, saw with his ruach hakodesh that Rav Ephrayim's daughter, Leah Rochel, was destined to become his wife.
Knowing that the Av Beis Din of Brod would not agree to marry off his daughter to a simple melamed, the Baal Shem Tov decided to reveal part of his true greatness and began a discussion with the two travelers on a deep concept in Torah. After witnessing his incredible brilliance and clarity of mind, the two litigants said to each other, "Why should we go through the trouble of traveling for another few days when we have a true scholar right here. Let us present our case to him."
The Baal Shem Tov agreed to hear the case and settled it to their mutual agreement. Rav Ephrayim then proceeded to have a very learned discussion with the young melamed and was overcome with admiration for his depth of knowledge and scholarship. After finding out that the melamed was not married, he then asked if he would agree to marry his daughter, Leah Rochel, and the Baal Shem Tov answered in the affirmative.
However, the Baal Shem Tov asked that no title be given him next to his name on the agreement. "Instead," he requested, "just write that you arranged a shidduch for your daughter with Yisroel ben Eliezer." Rav Ephrayim obliged, and they wrote the tannaim, each one receiving a copy.
Rav Ephrayim took leave of his future son-in-law and prepared to return home and inform his daughter of her future husband's true greatness. However, since he was not only the Chief Rabbi of Brod but of all the surrounding towns as well, and since he wasn't expected to return home for another few days anyway, he decided that he would visit some of the nearby villages to affirm that everything was in order.
In one of these villages, as fate would have it, Rav Ephrayim took ill and passed away suddenly without having had the opportunity to inform his family about the wonderful match he arranged for his daughter.
After shiva, his son Rav Gershon, who assumed his father's position, was surprised to find among his father's belongings a copy of the engagement agreement his father made for his sister. His surprise turned to consternation when he saw no great titles next to the chosson's name. "Is it possible that the chosson was an unlearned person?" he wondered. Nevertheless, he consoled himself, saying, "My father, of blessed memory, would never have arranged such a match. Most probably the chosson, in addition to being a true gaon, is also extremely humble and did not wish to be identified with any titles." Not knowing who the chosson was or where he lived, the only thing the family could do was wait and see.
Some weeks later, when the Baal Shem Tov concluded teaching his students, he informed their parents that they should hire a new teacher for the next term as he was leaving town. Arriving in Brod, the Baal Shem Tov donned the clothing of a simple laborer and came to the beis din.
Seeing a poor laborer standing at the door, Rav Gershon immediately instructed one of the attendants to give him food and money. However, the attendant returned saying that he told him he did not come for a donation, but rather to speak about a private, personal matter with the Rav.
Wondering what it could possibly be about, Rav Gershon agreed, and when everyone else left the room, the visitor entered. Studying his visitor as he entered, Rav Gershon saw that he raised his hand to the mezuzah but did not touch it. This man obviously had no education. However, as he stepped forward, he took out a piece of paper, presented it and said, "I am Yisroel ben Eliezer who, with your father's agreement, is to marry your sister."
Rav Gershon was dumbstruck. The paper was a copy of the tannaim. "How could his father agree to a match with such an ignoramus?" he thought. "Surely there had to be a mistake." But after examining both documents, he saw that indeed they were identical. There was no mistake: his father had arranged an unthinkable match.
Quickly composing himself, Rav Gershon offered Yisroel a substantial amount of money to annul the agreement. The Baal Shem Tov replied, "I don't want your money, nor would I allow you to nullify your father's wishes. Call for your sister and I will speak to her. If, afterwards, she does not want to go through with the marriage, I will agree to nullify it without any payment."
Rav Gershon immediately called his sister. When she arrived, he informed her that her chosson had arrived. However, he warned her, he was a total ignoramus. "Nevertheless," he added happily, "he is willing to release you after you meet with him for a few minutes."
Moving to a quiet corner out of earshot from Rav Gershon, the Baal Shem Tov revealed to Leah Rochel who he really was. He told her that for the foreseeable future, he would have to hide his greatness, even from her family. In addition, he warned her that during that time, they would be living in great deprivation. Then he added, "Your brother is shaken that I didn't kiss the mezuzah, but he is unaware that the mezuzah is posul."
Leah Rochel then approached her brother who said to her, "Now that you see what he is, let's get rid of him. You will surely marry someone much greater than he!" "Dear brother," she replied, "since father arranged it, he must have seen some special quality in him that we can't see. And if it is not in him, perhaps we are destined to have a great son. I am going to marry him and fulfill father's wishes."
Horrified by her answer, Rav Gershon tried once more to convince her to change her mind. He told her that when the man entered the room, he merely raised his hand and didn't even touch the mezuzah. "It's not just that he isn't a talmid chocham, he doesn't even know the basics of Yiddishkeit," bemoaned Rav Gershon.
Knowing who her fiancée really was, but not being allowed to disclose it publicly, she answered her brother in an off-handed manner, "Perhaps the mezuzah is not kosher." Hoping to prove her wrong, Rav Gershon immediately checked the mezuzah. To his bafflement, he saw that it was indeed posul!
Halachic Note: It is customary to touch a mezuzah as one passes the door, in order to acknowledge G-d's presence and providence within every place, above and below. Some people kiss their hand and place it on the mezuzah to show love for the mitzvah. (Yoreh Deah, Ch. 285:2, see Rema, Taz, and Birkei Yosef)
From the above story, it would seem that one should not kiss a mezuzah that one knows to be un-kosher.
From the forthcoming book by Rabbi Aaron L. Raskin.