Combine the mangoes, onion, vinegar, brown sugar, raisins, ginger, garlic, mustard seeds, cumin, cinnamon, red pepper flakes if using, and salt in a medium saucepan.
Bring the mixture to a gentle boil over medium heat, stirring to dissolve the sugar.
Reduce the heat to low and simmer, stirring occasionally, until the chutney is thick, glossy, and the mango has broken down slightly, about 35 to 40 minutes.
Taste and adjust the seasoning with more salt if needed. Remove from the heat and let cool.
Transfer to a clean jar or container. Serve chilled or at room temperature.