There are two customs in this regard, and either may be followed. Some authorities maintain that when a doorway is fitted with actual doorposts of wood or metal, the mezuzah should be affixed on these rather than on the walls of the doorway. This is true even if it would mean that the mezuzah would then be more than a tefach away from the outer edge of the doorway.[A]
According to these opinions, even if there is no space on the inner face of wooden post to place the mezuzah, it should be affixed on the front of the wooden post rather than on the walls of the doorway. Since the mezuzah is within the doorway and under the lintel, it may face outward.
Other authorities hold that one should put the mezuzah on the cement or brick surface if that is the outer tefach. However, even these authorities point out that if the wooden doorpost is thick and protrudes into the doorway more than a tefach, the mezuzah must be placed on it.[B]
 Chovas HaDar 8:3; Sha’arei HaMezuzah 12:9; Aruch HaShulchan 287:7; Pitchei Mezuzot 28:10.
 Agur B’ohalecha 14:4.
 Agur B’ohalecha 13:6.