Abu Dawud Book 2, Hadith Number 481.
Narated By Ubadah ibn as-Samit : We came to Jabir ibn Abdullah who was sitting in his mosque. He said: The Apostle of Allah (PBUH) came to us in this mosque and he had a twig of date-palm of the kind of Ibn Tab. He looked and saw phlegm on the wall towards qiblah. He turned to it and scraped it with the twig.
He then said: Who of you likes that Allah turns His face from him? He further said: When any of you stands for praying, Allah faces him. So he should not spit before him, nor on his right side. He should spit on his left side under his left foot. If he is in a hurry (i.e. forced to spit immediately), he should do with his cloth in this manner. He then placed the cloth on his mouth and rubbed it off.
He then said: Bring perfume. A young man of the tribe stood and hurried to his house and returned with perfume in his palm. The Apostle of Allah (PBUH) took it and put it at the end of the twig. He then stained the mark of phlegm with it.
Jabir said: This is the reason you use perfume in your mosques.