Cook the elbow macaroni according to package instructions until al dente. Drain and set aside.
In a large skillet, heat the olive oil over medium heat. Add the diced onion and sauté until translucent, about 3-4 minutes.
Stir in the minced garlic, Italian seasoning, and red pepper flakes (if using). Cook for another minute until fragrant.
Add the diced tomatoes and chopped spinach to the skillet. Cook for about 2-3 minutes until the spinach wilts.
In a separate saucepan, whisk together the milk and flour over medium heat. Cook until the mixture thickens, about 5 minutes.
Reduce the heat to low and stir in the mozzarella and Parmesan cheese until melted and smooth. Season with salt and pepper to taste.
Combine the cooked macaroni with the cheese sauce and vegetable mixture. Stir until well combined.
Transfer the mac and cheese to a greased baking dish and bake in a preheated oven at 350°F for 20 minutes, or until bubbly and golden on top.
Garnish with fresh basil before serving.