<p style='text-indent:20px;'>In this paper, we prove sharp gradient estimates for positive solutions to the weighted heat equation on smooth metric measure spaces with compact boundary. As an application, we prove Liouville theorems for ancient solutions satisfying the Dirichlet boundary condition and some sharp growth restriction near infinity. Our results can be regarded as a refinement of recent results due to Kunikawa and Sakurai.</p>