Functions in two distinct reactions of the de novo folate biosynthetic pathway. Catalyzes the addition of a glutamate residue to dihydropteroate (7,8-dihydropteroate or H2Pte) to form dihydrofolate (7,8-dihydrofolate monoglutamate or H2Pte-Glu). Also catalyzes successive additions of L-glutamate to tetrahydrofolate or 10-formyltetrahydrofolate or 5,10-methylenetetrahydrofolate, leading to folylpolyglutamate derivatives. 7,8-dihydropteroate + ATP + L-glutamate = 7,8-dihydrofolate + ADP + H(+) + phosphate (6S)-5,6,7,8-tetrahydrofolyl-(gamma-L-Glu)(n) + ATP + L-glutamate = (6S)-5,6,7,8-tetrahydrofolyl-(gamma-L-Glu)(n+1) + ADP + H(+) + phosphate 10-formyltetrahydrofolyl-(gamma-L-Glu)(n) + ATP + L-glutamate = 10-formyltetrahydrofolyl-(gamma-L-Glu)(n+1) + ADP + H(+) + phosphate (6R)-5,10-methylenetetrahydrofolyl-(gamma-L-Glu)(n) + ATP + L-glutamate = (6R)-5,10-methylenetetrahydrofolyl-(gamma-L-Glu)(n+1) + ADP + H(+) + phosphate Binds 2 Mg(2+) ions per subunit. Cofactor biosynthesis; tetrahydrofolate biosynthesis; 7,8-dihydrofolate from 2-amino-4-hydroxy-6-hydroxymethyl-7,8-dihydropteridine diphosphate and 4-aminobenzoate: step 2/2. Cofactor biosynthesis; tetrahydrofolylpolyglutamate biosynthesis. Monomer. Belongs to the folylpolyglutamate synthase family.