Mercury is the planet closest to the sun and therefore gets more direct heat​. But it is not the hottest planet.
Venus is the hottest planet in the solar system. Although Venus is not closest to the sun, its dense atmosphere traps heat. As a result, temperatures on Venus are higher than the temperature on Mars.