Preheat oven to 350 degrees F Combine Cheddar and mozzarella cheese in a small bowl; place 3 cups cheese mixture into a 9x13-inch baking dish.
Melt butter in a large skillet over medium heat; cook and stir mushrooms, onions, and red pepper until vegetables are tender, about 5 minutes; drain.
Spread vegetables over cheese mixture.
Top mushroom mixture with ham; sprinkle with remaining 1 cup cheese mixture.
Beat eggs in a bowl; mix in milk, flour, parsley, basil, salt, and pepper.
Slowly pour egg mixture into baking dish.
Bake in preheated oven until a knife inserted near the center comes out clean, 35 to 40 minutes. Let stand 10 minutes before cutting.