This test finds out what's causing your lung infection. Sputum, or phlegm, is the mucus that settles in the lower airways of your lungs when you have an infection or a chronic illness.