Catalyzes the hydrolysis of melibiose and alpha-galactosides of the raffinose family of oligosaccharides (RFOs) such as raffinose and stachyose. Cannot act on polymeric substrates such as locust bean gum. Hydrolysis of terminal, non-reducing alpha-D-galactose residues in alpha-D-galactosides, including galactose oligosaccharides, galactomannans and galactolipids. Binds 1 Mn(2+) ion per subunit. Binds 1 NAD(+) per subunit. Homodimer. Repressed by the transcriptional regulator MelR. Induced by melibiose and raffinose. Belongs to the glycosyl hydrolase 4 family.