In mid 2009 I had the same porblem, and my dealer said as with everone else that the EGR valve would need to be replaced. So like a nob I paid up almost £400 for a new valve, clearing the problem. About 1 month later the lights came on again, went back to the dealer who replaced the valve again. That lasted another month, and started all over again.
I did a little searching on the net to find that this was getting a more and more common fault with Mazda 6's built between 2003 and 2005, and was not as quoted by Mazda dealers as a EGR fault but something to do with fitting the wrong size and thickness of gasket on the EGR, they changed it for a larger gasket and all was fine for a month, and then it started all over again. They fitted a larger gasket and for the last two years it has been fine, up until this weekend, when the lights have been flashing on and off for 3 days now. Booked it in for a diag and will post what the report is, betcha they say it is a faulty EGR again, I will be not falling for that one again. Apparently Mazda have known all along there has been a fault on some vehicles and have not seen it to be serious enough to do a factory recall.