The Sony Xperia M5 is a water- and dust-resistant Android smartphone produced by Sony and released in August 2015. The M5 includes model numbers E5603, E5606, and E5653.
change the charging port / try a new charger if that doesn’t solve the problem take to an experienced technician to take a look on the charging ic or power that’s where the problem will come from