And with all the greatness of the mitzvah, nevertheless, if his hand cannot reach to buy both tefillin and a mezuzah, we say in the Yerushalmi of Megillah that he should buy tefillin, for a mitzvah that is a personal obligation is preferred. That is to say: that from tefillin the obligation upon him is fixed, whether he is in his house or whether he is on the way. But regarding mezuzah, when he is on the way—he is exempt. And likewise, if he does not have a house—he is exempt from it. And there is one who says that for us, who do not don tefillin except during the time of Kriyat Shema and prayer, if it is possible through borrowing—mezuzah is preferred (Magen Avraham in Orach Chaim siman 38, subsection 4). And beit din does not compel regarding the mitzvah of mezuzah, because it is a mitzvah whose reward is specified alongside it, and as I have written above in siman 240, see there. And one who becomes aware that there is no mezuzah on his doorway—it is forbidden for him to delay even a moment. And he should go to a sofer to buy a mezuzah and fix it immediately. And if it is Shabbat or Yom Tov when it is impossible to fix it, if he has another room—he should not sit in this room. And if he does not have one—it is permitted. And likewise on a weekday when the sofer is not here, and it is impossible to obtain it immediately (Pri Megadim Orach Chaim siman 31). And there are those who say that if the mezuzah is not inside a case—it is forbidden to place his hand upon it and to touch with his hand without an intervention, just as with a Torah (the Gaon Rabbi Akiva Eiger).
ועם כל גודל המצוה, מכל מקום אם אין ידו משגת לקנות תפילין ומזוזה, אמרינן בירושלמי דמגילה דיקנה תפילין, דמצוה שהיא חובת הגוף עדיף. כלומר: דמתפילין החוב עליו קבוע, בין כשהוא בביתו בין שהוא בדרך. אבל מזוזה כשהוא בדרך – פטור. וכן אם אין לו בית – פטור ממנה. ויש מי שאומר דלדידן שאין מניחין תפילין רק בשעת קריאת שמע ותפילה, אם אפשר בשאלה – מזוזה עדיף (מגן אברהם באורח חיים סימן ל"ח סעיף קטן ד). ואין בית דין כופין על מצות מזוזה, מפני שהיא מצוה שמתן שכרה בצדה, וכמו שכתבתי לעיל סימן ר"מ, עיין שם. ומי שנודע לו שאין מזוזה בפתחו – אסור לו להשהות אפילו רגע. וילך לסופר לקנות מזוזה ולקובעה מיד. ואם הוא שבת ויום טוב שאי אפשר לקובעה, אם יש לו חדר אחר – לא ישב בחדר זה. ואם אין לו – מותר. וכן בחול כשאין הסופר בכאן, ואי אפשר להשיגה מיד (פרי מגדים אורח חיים סימן ל"א). ויש אומרים דאם אין המזוזה בתוך תיק – אסור להניח ידו עליה וליגע בידו בלי הפסק, כמו בתורה (הגאון רבי עקיבא איגר).