Wash the spinach and put it in a large saucepan with just the water that clings to its leaves. Heat for 1-2 mins until gently wilted, then tip into a colander and allow to cool. Once cool, squeeze out the excess water and chop finely.
Heat the oil in a frying pan and gently cook the onion for about 5 mins until softened. Stir in the garlic and chilli flakes, and cook for 1 min more. Tip into a bowl, add the spinach, courgettes, rice and cheese, and toss together.
Beat the 2 large eggs with the mustard, a pinch of salt and a good grinding of black pepper. Add to the spinach mixture and mix well. Heat oven to 200C/180C fan/gas 6. Put a baking sheet in the oven to preheat. Cut the pastry in half and roll 1 piece out on a lightly floured work surface until you have a sheet that measures 32 x 17cm. Place in a 30 x 15cm tin and prick it well all over the base. Roll out the remaining piece of pastry to the same size.
Spoon the spinach mixture into the pastry base. Beat together the milk and remaining medium egg, then brush the edges of the pastry with it. Lay the other sheet of pastry over the top and press down gently to seal. Brush the top with a little more beaten egg and sprinkle with the sesame seeds.
Place the tin on the preheated baking tray and bake for 10 mins, then reduce the temperature to 160C/140C fan/gas 4 and bake for a further 30 mins until the pastry is golden. Leave to cool for 10 mins before cutting into squares.