Abstract Background Previous studies have shown that secondary metabolites of Bacillus subtilis strain Z15 (BS-Z15) are effective in treating fungal infections in mice. To evaluate whether it also modulates immune function in mice to exert antifungal effects, we investigated the effect of BS-Z15 secondary metabolites on both the innate and adaptive immune functions of mice, and explored its molecular mechanism through blood transcriptome analysis. Results The study showed that BS-Z15 secondary metabolites increased the number of monocytes and platelets in the blood, improved natural killer (NK) cell activity and phagocytosis of monocytes-macrophages, increased the conversion rate of lymphocytes in the spleen, the number of T lymphocytes and the antibody production capacity of mice, and increased the levels of Interferon gamma (IFN-γ), Interleukin-6 (IL-6), Immunoglobulin G (IgG) and Immunoglobulin M (IgM) in plasma. The blood transcriptome analysis revealed 608 differentially expressed genes following treatment with BS-Z15 secondary metabolites, all of which were significantly enriched in the Gene Ontology (GO) and Kyoto Encyclopedia of Genes and Genomes (KEGG) terms for immune-related entries and pathways such as Tumor Necrosis Factor (TNF) and Toll-like receptor (TLR) signaling pathways, and upregulated expression levels of immune-related genes such as Complement 1q B chain (C1qb), Complement 4B (C4b), Tetracyclin Resistant (TCR) and Regulatory Factor X, 5 (RFX5). Conclusions BS-Z15 secondary metabolites were shown to enhance innate and adaptive immune function in mice, laying a theoretical foundation for its development and application in the field of immunity.