In Eretz Yisrael it’s many times difficult to place the mezuzah on the door going into a building where people live since the way the door closes there is no room on the doorpost to place the ‘mezuzah’. I was once by a building and noticed they put the mezuzah inside the building on door on the outside of the doorpost (not under the mashkof at all.) Are they yotzee b’dieved? What seems most lichatchila like is done in many places is to make a hole in the door post itself to place the mezuzah so the door can close and still have the mezuzah within the mashkof and in a proper place…
(Hopefully this description makes sense as I’m sure those living here know what I am referring to with the typical doors leading into a building.)
The ideal, as you rightly note, is to make a hollow in the doorpost, and place the mezuzah in the hollow.
Placing the mezuzah on the outside of the doorpost involves a dispute among rishonim, which is reflected by a dispute between the Shulchan Aruch and the Rema (289:2; see also Shach).
The Aruch Ha-Shulchan (289:13) rules that even according to the Rambam, a mezuzah placed on behind and attached to the doorpost is fine bedieved.