The Messenger of Allah(ﷺ) said: Spitting phlegm in the mosque... The narrator then transmitted the rest of the tradition to the same effect.
Sunan Abi Dawud Book 2, Hadith 86