In general, it's best to stick with the charger your phone came with.
This is true, but it's been my experience that USB charging is about the worst way to charge due to the cables going bad very quickly. Needless to say, I've use a few different chargers and many, many cables. Here's the main things to pay attention to...
Every charger should have an output rating listed on it (the input rating typically isn't that important, and stay away from any charger that doesn't specifically list the ratings). The USB standard voltage is 5V, which you shouldn't have to worry about. If it's a USB charger, it will be the same across the board. The really important number to look at is the amperage rating, which is how much current the charger puts out. Think of it like two buckets, one slightly higher than the other, and connected by a hose. Water will flow from the higher bucket (the charger's higher 5V), to the lower bucket (the battery's lower voltage). The size of the hose determines how fast the water flows (current/amperage). That's a little simplistic, but works to give you an intro into knowing about chargers.
That said, the stock charger is rated at 1.5A (amps) and that's what the phone needs to be able to charge and still be operational. To connerp12, the charger from your Razr is rated at .75A (750mA). The M8 doesn't ALWAYS suck a full 1.5A from the charger, but it could eventually over work the weaker charger and burn it out. You could even loose charge while plugged in, depending on your usage. Going back to the bucket example, it's like having a 1" hose between the buckets for charging, but having another 2" hole in the bottom bucket draining water (your usage). Even if the top bucket had infinite water, it'd never keep up with the hole in the bottom bucket.
The last thing to remember is the phone pulls the current, the charger doesn't push it. So getting a higher than stock rated charger won't charge the phone any faster or cause any damage, defects excluded of course. I personally have my M8 on a stronger, 2.1A charger most of the time and the phone before that too without any issues.
TL;DR version: Use a charger rated at least 1.5A (same as stock) or more for the M8.
I'm not sure what could be causing the corrosion, if that's what it really is. That's usually related to being wet, or defective battery/connections.