A 2.5 year old phone? I would bet the battery is very near end of life (approaching 1000 cycles). And yes, dirt and corrosion will cause problems on the charging contacts, but you problem sounds like a loose wire or the charger is not powerful enough and the voltage is sagging under load so the phones charge controller shuts down.
__________________
|