The Messenger of Allah ﷺ said, "Whoever enters this mosque and spits, clears his throat, or coughs up phlegm, let him dig into the ground, move away, and bury it. If he does not do so, let him spit into his garment and then take it out with him."
حدثنا أبو عامر حدثنا أبو مودود حدثني عبد الرحمن بن أبي حدرد الأسلمي قال سمعت
قال رسول الله ﷺ من دخل هذا المسجد فبزق أو تنخم أو تنخع فليحفر فيه وليبعد فليدفنه فإن لم يفعل ففي ثوبه ثم ليخرج به
Its chain of transmission is sahih. As for the Abu Dawud mentioned in it, I think it is a mistake, and the correct name is Abu Mawdud, who is Abdul-Aziz Ibn Abu Sulayman Hudhali Madani Qass, for he is the one who narrates from Abdul-Rahman bin Abu Hadrad. This hadith has already passed in abridged form under 7522, where it correctly has Abu Mawdud, and it will also come again correctly under numbers 10098 and 10902.