Touching the Mezuzah upon leaving and entering ones home:
There are opinions who say that when a person leaves the home, he is to place his [right] hand [i.e. middle finger] on the Mezuzah and say the verse “Hashem Yishmor Tzeisi Uvoi Meyata Viad Olam/G-d will guard my leaving and returning from now and ever”. Similarly, one is to place his hand on the Mezuzah upon entering the house. [Some Poskim say one is to recite the above verse also when touching the Mezuzah upon entering the home. Upon touching the Mezuzah one is to Daven to Hashem to gaurd him using the name Shakaiy and that he be protected from the Yetzer Hara.]
Leaving the city: When leaving the city, one is to place his hand on the Mezuzah and say the verse of “Bishimcha Tal Atleh”. [One is to place his middle finger on the Mezuzah, as will be stated below.]
Summary [based also on Q&A]:
Upon entering and exiting a home one is to place the middle finger of his right hand on the Mezuzah and kiss it. Upon exiting the home, one is to say the verse “Hashem Yishmor Tzeisi Uvoi Meyata Viad Olam” and pray to be guarded [physically] and protected from the Yetzer Hara. Upon leaving the city one is say the verse of “Bishimcha Tal Atleh.”
How to touch the Mezuzah:
The Arizal states that one should place his Ama, which is the middle finger, over the name “Sha-kai”, and kiss it. One is then to Daven to Hashem to gaurd him using the name Shakaiy and that he be protected from the Yetzer Hara. [The Rebbe was accustomed to touch the Mezuzah using his middle finger, although he did not kiss it.]
With which hand is one to touch the Mezuzah?
One is to touch the Mezuzah using his right hand.
Lefty: A lefty is to touch the Mezuzah using his left hand.
Kissing the hand:
Kissing the Mezuzah before sleep:
Prior to retiring to one’s bed for the night one is to touch [and kiss] the Mezuzah.
Children: It is customary in all Jewish homes for children to kiss the Mezuzah of their room prior to going to sleep. This internalizes the idea that Hashem watches and guards over them. [Doing so enters Kedusha into the child from a youg age and assists him in his service of G-d in the future.]
Is one to touch/kiss the Mezuzah of every room he enters/exits?
The above-mentioned custom of touching/kissing the Mezuzah was only said regarding the Mezuzah of the main entrance of the home, upon exiting and entering the home. Nevertheless, the custom today is to touch/kiss the Mezuzah upon exiting and entering every room. The Rebbe was witnessed to touch the Mezuzah of every room that he entered/exited.
May one touch/kiss the Mezuzah if it does not have a covering?
Some Poskim rule a Mezuzah which does not have any covering over the parchment [not even a plastic wrap] should not be touched with ones bare hands. It is rather to be touched with a cloth, such as with the use of one’s sleeve and the like. Other Poskim however rule that there is no prohibition in touching the parchment. Practically, the widespread custom is not to be stringent and people hence touch and hold the Mezuzah directly even without washing hands. Nevertheless, it is proper for every person to be stringent upon himself and avoid touching the parchment of a Kosher Megillah/Mezuzah anytime, unless he washes his hands beforehand, or holds onto it using a cloth.
 Rama 285/2; brought in Yosef Ometz 454; Kitzur SHU”A 71/4
 Maharil Likkutim Maharash 8-9 [p. 29] “Every time one leaves the entrance of his home he is to place his hand on the Mezuzah and say…”; Avoda Zara 11a regaridng Unkulos who placed his hand on the Mezuzah upon traveling and said the above-mentioned verse; See also Menachos 33b
Other opinions: Some Poskim would not touch the Mezuzah upon exiting, but rather would simply look at it. If, however, he would travel outside the city, then he would touch the Mezuzah. [Leket Yosher p. 60 that so was custom of Terumas Hadeshen] Many Gedolei Yisrael were not accustomed to touch or even look at the Mezuzah upon exiting a room. [See Kevius Mezuzah Kehilchasa 14/2 footnote 4; Orchos Rabbeinu 3/164]
 See Q&A!
 See Q&A!
 Tehillim 121/8
 Rama ibid based on Midrash; Maharil ibid 9; Divrei Chamudos on Rosh Mezuzah 26; Unkulus in Avoda Zara ibid
Other verses: Some say one is to recite the verse “Hashem Shomrei Hashem Tzeili Al Yad Yimini” [Maharil ibid 8]
 Rama ibid [omitted in Maharil]
 Yad Haketana 3/12; Implication of Levush 285
 Arizal, brought in Likkutei Torah Vaeschana “Touch the Mezuzah with the finger called Ama and then kiss it” brought in Matzas Shmurim and Birkeiy Yosef 285, Misgeres Hashulchan on Kitzur 11/18
 Shach 285/4; Darkei Moshe 285; Maharil Likkutim Maharash 7 [p. 29]; Rashal in Yam Shel Shlomo Yevamos 1/3
 This verse is the Gematria of “Kuzu”, which is the Divine name written on the outside of the Mezuzah. [Poskim ibid] Some Poskim write that one is to say the above verse three times. [Rashal ibid] For other verses said near a Mezuzah, see Siddur Shelah and Kav Veyashar 1/24 and 85
 Arizal, brought in Likkutei Torah Vaeschana, Matzas Shmurim, Birkeiy Yosef 285, Misgeres Hashulchan on Kitzur 11/18; Pischeiy Shearim 285/2
 Maaseh Melech p. 43
 Beir Moshe 2/1-3; Dinei Iter 25/3; However, see Hiskashrus 467 p. 18 that at times the Rebbe placed his right hand and at times his left hand
 Seee Admur Kama 2/3-6; Basra 2/4 regarding giving precedence to the right
 Beir Moshe 2/2-4; Dinei Iter ibid
 Arizal, brought in Likkutei Torah Vaeschana “Touch the Mezuzah with the finger called Ama and then kiss it” brought in Matzas Shmurim and Birkeiy Yosef 285, Misgeres Hashulchan on Kitzur 11/18; Likkutei Dibburim Likkut 32 Vol. 4 p. 784 “When I was three years old twice a day, in th morning upon awakening and at night upon going to sleep, my mother would lift me up to kiss the Mezuzah.”; Toras Menachem 1987 2/647 “Every Jewish home is careful that the children kiss the Mezuzah…”; See Pischeiy Shearim 285/2; See Yesod Veshoresh Havoda Shaar 8/8, and Shaareiy Efraim 10/4 regarding kissing the hand that touched a Sefer Torah
 Heard from Rav Groner, brought in Hiskashrus 467
 Kitzur SHU”A 71/4 “Prior to going to bed one is to walk to the Mezuzah and place his hands on it and say “Hashem Shomri…”
 Toras Menachem 1987 2/647; Sefer Hasichos 1992 p. 89; Likkutei Dibburim Likkut 32 Vol. 4 p. 784 “When I was three years old twice a day, in the morning upon awakening and at night upon going to sleep, my mother would lift me up to kiss the Mezuzah.”
 Heard from Rav Groner, brought in Hiskashrus 467; See however Hiskashrus there for a Shemua that the Rebbe said to Rebbetzin Pozner in Yechidus that it suffices to touch the Mezuzah of the entrance to the home.
 Teshuvas R. Akivah Eigar 58; brought in Pischeiy Teshuvah 285/4; Implication of stringent opinion in Rama O.C. 147/1, as learns M”A 147/1
The reason: As one is to be stringent not to touch any Holy Scripture with ones bare hands [Rama 147/1 [stringency]; M”A 147/1 [forbidden]; Haeshkol Hilchos Talmud Torah 12; Mor Uketzia 691; Sheilas Yavetz [forbidden, brought in Machazik Bracha 691/3]; Elya Raba 147/1 [stringency] brought in Shaareiy Teshuvah 691/4] and the same would apply to a Mezuzah, as it is included within Kisvei Kodesh. [Pischeiy Teshuvah ibid]
The Michaber 147/1 rules that it is forbidden to directly touch a Sefer Torah without a cloth. The Rama ibid brings an opinion [Aguda and Tosafos] that extends this prohibition to all Kisvei Kodesh. The Rama concludes that the custom is unlike this opinion, although it is proper to be stringent if one did not wash his hands. The M”A ibid explains that in truth the reason that we are not accustomed to be stringent is because this prohibition only applies to Kisvei Kodesh that is written with ink on parchment and since our books are not written in this method it is thus permitted to touch them directly. The conclusion of the Rama that it is proper to be stringent is thus superfluous. However, a Kosher Megillah which is written with ink on parchment retains the above restriction from the letter of the law and not just as a stringency. [M”A ibid] The Elya Raba ibid however concludes that the ruling of the Rama “it is proper to be stringent” is actually referring to a Kosher Megillah, and it is hence not required to be stringent from the letter of the law as rules the M”A. [The above dispute would likewise apply to a Mezuzah.]
Other opinions: The Taz 286/5 implies that he is not bothered by this issue as he does not mention it in his reasoning’s behind why one should cover the parchment.
 Rama O.C. 147/1 as understood by Elya Raba ibid that custom is to be lenient; Radbaz 2/771; Shvus Yaakov 11; Panim Meiros 1/76; Shaareiy Teshuvah 691/4; Shev Yaakov 11; Aruch Hashulchan 147/4-6
 Radbaz 2/771 [“we have never seen anyone stringent in this”]; Panim Meiros 1/76; Shaareiy Teshuvah 691/4
 Rebbe Akiva Eiger ibid; Shaareiy Teshuvah ibid; Keses Hasofer 19; M”B 147/4; Kaf Hachaim 147/7; Hagahos Chasam Sofer that his teacher Reb Nassan Adler was careful not to touch it directly and so was the custom of the Chasam Sofer himself.