what have you attempted to do to get the remote to work? they have little batteries in them that you can pick up at any Mazda parts dept. thats the easiest thing to do first.
if you insist on buying a new remote, then it will have to be programmed to the vehicle. also some of the 6's come with an advanced keyless system, that will require a dealer to program the remote to the vehicle.