The modulation of intestinal flora by various polysaccharides has been shown to mitigate disease progression. Recent research reveals a significant link between intestinal flora and the progression of mastitis. This study demonstrates that the oral administration of Angelica sinensis polysaccharide (ASP) reduces mammary inflammation and blood-milk barrier (BMB) damage induced by Staphylococcus aureus in mice, primarily through the modulation of intestinal flora. The beneficial effects of ASP were negated when antibiotics disrupted the gut microbiota in mice. Furthermore, fecal microbiota transplantation (FMT) from ASP-treated mice to recipients markedly alleviated symptoms of S. aureus-induced mastitis. Oral ASP not only enhances gut microbial diversity but also shifts its composition, increasing the abundance of Lachnospiraceae_NK4A136 while reducing Erysipelatoclostridium. Metabolomic analysis revealed that ASP alters intestinal metabolic pathways, elevating levels of metabolites, such as tabersonine and riboflavin. Notably, tabersonine was found to ameliorate S. aureus-induced mastitis. These results suggest that targeting intestinal flora and metabolism through polysaccharides could serve as a promising strategy for mastitis intervention and potentially for other infectious diseases, as well.