Unfortunately, no. It has to be a charger which bears the Qualcomm Quick Charge logo like this: https://goo.gl/images/vZLCZB
Either the lightning bolt symbol, or the charger will say "Quick Charge 2.0" etc. on it.
The M8 specifically supports QC 2.0, although other official QC chargers will work, to some degree. QC 3 and 4 chargers will charge at QC 2.0 speed (not as fast as QC 3 and 4). A QC1 charger will work (faster than standard charger), but not as fast as QC 2.0 speed.
Unfortunately, Samsung uses their own fast charge technology, which isn't compatible with other brand devices (such as HTC). Blame it on the phone manufacturers, who are trying to differentiate their products with their own fast charge technologies. Breaking the native Qualcomm Quick Charge function, even for devices (such as Samsung, and there are others) that use Qualcomm Snapdragon chipsets.