What is bloody sputum?

That is, blood in the sputum, bleeding from the mucous membrane of the respiratory tract or bleeding from the mouth accompanied by coughing sputum due to various etiologies.
Blood in the sputum can occur when inflammatory reactions such as infection invade the respiratory capillaries. Tumour tissues are rich in blood supply and brittle in texture, so blood vessels may rupture during severe coughing and cause bleeding; coughing up blood may also be caused by local necrosis of the tumour or vasculitis.
Blood from the nose may flow backwards into the pharynx and be coughed out with the sputum or bleeding from the mouth may be spat out with the sputum. Acute left heart failure and obstruction of pulmonary venous blood flow back to the left atrium leads to acute pulmonary oedema and pink foamy sputum.