Anal gland

The anal glands or anal sacs are small glands near the anus in many mammals, including dogs and cats. They are paired sacs on either side of the anus between the external and internal sphincter muscles. Sebaceous glands within the lining secrete a liquid that is used for identification of members within a species. These sacs are found in many species of carnivorans, including wolves, bears, sea otters and kinkajous.
Humans.
The anal glands are in the wall of the anal canal. They secrete into the anal canal via anal ducts which open into the anal crypts along the level of the dentate line. The glands are at varying depths in the anal canal wall, some between the layers of the internal and external sphincter (the intersphincteric plane). The cryptoglandular theory states that obstruction of these ducts, presumably by accumulation of foreign material (e.g. fecal bacterial plugging) in the crypts, may lead to perianal abscess and fistula formation.
Dogs and cats.
Dogs and cats primarily use their anal gland secretions to mark their territory, and generally will secrete small amounts of fluid every time they defecate. Many will often express these glands when anxious or frightened as well. Anal sac fluid varies from yellow to tan or brown in color. The consistency of the fluid ranges from thin, watery secretions to thick, gritty paste.
The inability to effectively express this fluid can lead to anal sacculitis. This is characterized by a build-up of fluid in the anal sac, an uncomfortable condition that can lead to pain and itching. Dogs and cats of any age may be affected, but dogs are far more likely to suffer from anal sacculitis than cats. Dogs and cats with anal glands that do not express naturally may exhibit specific signs, such as scooting the backside upon the ground, straining to defecate, and excessive licking of the anus. Cats may also defecate in areas outside the litter box.
Discomfort may also be evident with impaction or infection of the anal glands. Anal sac impaction results from blockage of the duct leading from the gland to the opening. The sac is usually non-painful and swollen. Anal sac infection results in pain, swelling, and sometimes abscessation and fever.
Initial treatment usually involves the manual expression of the anal sacs, most often by a veterinary professional. The frequency of this procedure depends on the patient's individual degree of discomfort but can range from weekly to every few months. Treatment may include lancing of an abscess or antibiotic infusion into the gland in the case of infection. The most common bacterial isolates from anal gland infection are "E. coli", "Enterococcus faecalis", "Clostridium perfringens", and "Proteus" species. Increasing dietary fiber is also commonly recommended.
Anal sacs may be removed surgically in a procedure known as anal sacculectomy. This is usually done in the case of recurrent infection or because of the presence of an anal sac adenocarcinoma, a malignant tumor. Potential complications include fecal incontinence (especially when both glands are removed), tenesmus from stricture or scar formation, and persistent draining fistulae.
Opossums.
Opossums use their anal glands when they "play possum". As the opossum mimics death, the glands secrete a foul-smelling liquid, suggesting the opossum is rotting. Opossums are not members of the carnivora, and their anal sacs differ from those of dogs and their relatives.
Skunks.
Skunks use their anal glands to spray a foul-smelling and sticky fluid as a defense against predators.
Beavers.
An extraction of castoreum, the scent glands from the male and female beaver are used in perfumery and as a flavor ingredient.