The Talmud is clear that the mezuzah should be within the doorway.[1] Where this is unfeasible, the custom is to place it on the outer face of the doorpost within a tefach of the opening.[2] If this is not an option, one may even place it on the inner face of the doorpost or on the inner wall.[3]
However, though this is the custom, since some opinions hold that these solutions are questionable, some individuals widen the doorway by welding extensions onto both doorposts and onto the lintel. However, merely welding a small base for the mezuzah[A] or even extending the right post fully[B]
is not a solution because the mezuzah would still be outside the doorframe.[4]
[1] Menachos 32b.
[2] Rema Y.D. 289:2; Chayei Adam, Nishmas Adam 15:21:1; Kitzur Shulchan Aruch 11:9; Shevet HaLevi 3:151; Chovas HaDar 8:3:2; Agur B’ohalecha 14:12.
[3] Kitzur 11:9; Agur B’ohalecha 14:12. Chayei Adam (15:21, Nishmas Adam 15:1) writes that it should be placed on the post and not on the inner wall. Agur B’ohalecha (14:15:39) asserts that once it is on the inner face, it makes no difference whether it is on the post or on the wall.
[4] Agur B’ohalechah (14:13-14) opines that the small base achieves nothing as it is the equivalent of putting it on the front outside of the frame. Ironically, he holds that building a full right extension is worse than attaching a small base. Cf. Chovas HaDar 9:3:22, who allows extending the right panel if there is no other choice.