The epithelium of the mammary gland (MG) fulfills three major functions: nutrition of progeny, transfer of immunity from mother to newborn, and its own defense against infection. The defense function of the epithelium requires the cooperation of mammary epithelial cells (MECs) with intraepithelial leucocytes, macrophages, DCs, and resident lymphocytes. The MG is characterized by the secretion of a large amount of a nutrient liquid in which certain bacteria can proliferate and reach a considerable bacterial load, which has conditioned how the udder reacts against bacterial invasions. This review presents how the mammary epithelium perceives bacteria, and how it responds to the main bacterial genera associated with mastitis. MECs are able to detect the presence of actively multiplying bacteria in the lumen of the gland: they express pattern recognition receptors (PRRs) that recognize microbe-associated molecular patterns (MAMPs) released by the growing bacteria. Interactions with intraepithelial leucocytes fine-tune MECs responses. Following the onset of inflammation, new interactions are established with lymphocytes and neutrophils recruited from the blood. The mammary epithelium also identifies and responds to antigens, which supposes an antigen-presenting capacity. Its responses can be manipulated with drugs, plant extracts, probiotics, and immune modifiers, in order to increase its defense capacities or reduce the damage related to inflammation. Numerous studies have established that the mammary epithelium is a genuine effector of both innate and adaptive immunity. However, knowledge gaps remain and newly available tools offer the prospect of exciting research to unravel and exploit the multiple capacities of this particular epithelium.