The most important part of a mezuzah is invisible. The thoughts and intentions of the sofer breathe soul into the letters, transforming a piece of animal hide into a pulsating “power-pack.”
As the sofer sits down to write a mezuzah he must focus and say: “Behold I am writing for the sake of the holiness of mezuzah.” If these words were in the Sofer’s mind but not verbally expressed at the outset, the mezuzah is invalid. Although this one declaration is effective for the duration of the entire writing process, if the sofer takes a break for eating, sleeping, or other activities, ideally, he should repeat the declaration upon resuming.
That’s not all. A special declaration is verbalized before the writing of every one of the many Divine names in the mezuzah: “Behold I am writing for the sake of the holiness of the Divine Name.” Before adding this enhanced level of intention, the sofer first sanctifies the ink on his quill by writing a letter in the scroll.
Aside from these thoughts, exceptionally learned sofrim infuse their writing with kabbalistic intentions, especially when inscribing the Divine names. A sofer must also keep in mind at all times the many intricate rules and protocols of proper halachic writing.
Once he begins writing the name of Hashem, he is forbidden to interrupt until he finishes. I once arrived at the home of a sofer for a meeting. I knew he was there, but for some reason he did not respond to the doorbell. Finally, he appeared and explained apologetically that even if I was David, King of Israel, he could not have come to the door earlier as he was in the middle of writing the Name of G-d.
The Mishnah records that a certain scribe had mastered a special method of writing the four letters of G-d’s name simultaneously with four quills tied to his fingers. He mastered this to ensure that the Name would never be in an incomplete state.
All of this requires extraordinary focus, diligence, and devotion. It is no wonder that the Sages write that the most important quality of a sofer is his “fear of Heaven” — even more important than the beauty of his script. Additionally, our rabbis have asserted that the piety of the sofer enhances the holiness and power of the mezuzot he writes. Many sofrim are accustomed to purifying themselves before writing by immersing in a mikveh.
Fear of Heaven is a crucial quality for a more basic reason. Many of the errors that disqualify a mezuzah are undetectable, and some cannot be corrected later. An unscrupulous sofer can pass on an invalid mezuzah as kosher, with only Heaven as his witness. This is another reason why a person should be careful to purchase his scrolls from a reputable source.
We often are happy to spend money purchasing a beautiful mezuzah cover to grace our home. But we are in shock when we discover what a properly written kosher scroll costs. We must just remember: It’s the thought that counts!
 Shulchan Aruch Y.D. 274:1
 Shulchan Aruch Y.D. 276:2
 Rambam, Hilchos Tefillin 1:15
 Sotah 20a