Mucus is mainly composed of polysaccharides, which are long-chain carbohydrates. These molecules are stiff when dry, and sticky and slippery when wet. They are present in all types of organisms from bacteria to humans.
In vertebrates mucus is made by mucous membranes. Mucus may have antiseptic enzymes (such as lysozymes) and immunoglobulins (antigens). A major function of this mucus is to protect against infection by fungi, bacteria and viruses.
Mucus protects epithelial cells in the lungs, gut, genital, visual, and auditory systems in mammals; the epidermis in amphibians; and the gills in fish. Snails, slugs, hagfish, and certain invertebrates also produce external mucus. As well as a protective function, slime helps movement and plays a role in communication.
Mucus is produced in many parts of the body. All the alimentary canal, nose, and sexual organs have mucus glands which pass the mucus to the surfaces. The surfaces are mostly internal surfaces, though in some animals mucus covers the outside of the animal. Slugs are an example of this. Mucus glands are exocrine glands, so they pass their mucus to the surface along ducts.
Alkaline mucus change
- Singh P.K. et al 2002. A component of innate immunity prevents bacterial biofilm development. Nature 417 (6888): 552–5. 
- Purves, William. "Why don't our digestive acids corrode our stomach linings?". Scientific American. Retrieved 6 December 2012.
Second, HCl in the lumen doesn't digest the mucosa because goblet cells in the mucosa secrete large quantities of protective mucus that line the mucosal surface.
- Wang, Ying-Ying et al 2013. The microstructure and bulk rheology of human cervicovaginal mucus are remarkably resistant to changes in pH. Biomacromolecules 14 (12) 4429-35.