I got my 2006 M5 last May. So far a few minor things, but very reliable. Its is a solid car. My advise would be to search hard and find a reliable mechanic who knows their M5s. I would also suggest to take your prospective purchase to a shop and have things looked over. Anyone one or place selling a good used M5 will not have issue with this, and if they do stay clear.
Good luck and enjoy the car, I thank my stars every day I drive it. They are awesome machines.
Stay clear of one that has any mods, unless done correctly they can ruin an otherwise perfect car.