Mastitis is a common mammalian disease occurring in the mammary tissue and poses a major threat to agriculture and the dairy industry. Hordenine (HOR), a phenylethylamine alkaloid naturally extracted from malt, has various pharmacological effects, but its role in mastitis is unknown. The aim of this study was to investigate the role of HOR and its underlying mechanism in a lipopolysaccharide (LPS)-induced inflammatory response model of mouse mammary epithelial cells (EpH4-Ev) and mouse mastitis model. The experimental results showed that HOR attenuated LPS-induced mammary tissue damage (from 3.75 ± 0.25 to 1.75 ± 0.25) and restored the integrity of the blood−milk barrier. Further mechanistic studies revealed that HOR inhibited LPSinduced overactivation of the TLR4-MAPK/NF-κB signaling pathway and activated the AMPK/Nrf2/HO-1 signaling pathway. Additionally, HOR altered the composition of the intestinal microbiota in mice, ultimately reducing the extent of inflammatory injury (from 3.33 ± 0.33 to 0.67 ± 0.33) and upregulating the expression of tight junction proteins (ZO-1, occludin, and claudin-3). The findings of this study provide a theoretical basis in the rational use of HOR for the prevention and treatment of mastitis and the maintenance of mammalian mammary gland health.