As you quit smoking you can experience an uncomfortable cough. You can start to cough up black/brown mucous. What is happening is that your body's Cilia (which are tiny hair-like particles that line your lungs) are in a healing process.
They are first paralyzed and your body does not want to produce any mucus, therefore a dry cough sets in. As the cilia begin to heal themselves they start to clean all areas of your lungs. This is where you start to cough up all that awful mucus.
These symptoms can last day or weeks after you quit smoking. The healing is a long process of change, even though some of the benefits come more quickly than others. Try drinking more water, herbal tea and even cough drops or candy.
If you have a symptom that persists or seems worse than you expected, you should immediately consult a doctor. Its possible that your smoking has been masking symptoms of some illness, and when you stop smoking the symptoms abruptly become noticeable.
Smoking does mask symptoms, so it is important to really know what your body is going through. Regular appointments with your doctor can be beneficial to rule out anything medical.