From: Rabbi Moshe Sofer
To: Rabbi Avraham
The Chasam Sofer reconciles the Rambam's statement that a synagogue is exempt from mezuzah because it is kodesh with the Gemara Yoma's reasoning that it is not called beisecha. He explains that kodesh in the Rambam means a dwelling of the Shechinah rather than of a private individual, making it inherently not beisecha — not that the building possesses formal sanctity. He also rejects the theory that saleability determines a village synagogue's obligation, affirming instead that the presence of a residential dwelling is the deciding factor.
Source: Shu"t Chasam Sofer YD §281