A train driver crashed into the buffers at a station shortly after sending a WhatsApp message about the death of Formula 1 commentator Murray Walker.
The Merseyrail train was travelling at 40mph (64km/h) instead of 15mph (24km/h) when the cab derailed at Kirkby station on 13 March 2021.
At Liverpool Crown Court, 59-year-old Phillip Hollis admitted endangering passengers’ safety.
He was handed a 12-month prison sentence, suspended for two years.
Prosecutor David Polglase said the crash caused £450,000 worth of damage.
The court heard that none of the 12 passengers were hurt in the crash, while the train’s guard also escaped injury.
The service had been due to arrive at Kirkby, from Liverpool Central, at 18:52 GMT.
Mr Polglase said a review of Hollis’s phone showed a WhatsApp message received at 18:28 said: “RIP Murray”.
At 18:51, when the train was between Fazakerley and Kirkby, Hollis replied: “A great commentator”.
Mr Polglase said the message was a reference to motor racing commentator Murray Walker, whose death had been reported earlier that day.
Passing sentence, Judge David Potter said the train had been going too fast because Hollis was distracted by a combination of receiving and sending WhatsApp messages and leaning out of his cab to retrieve a bag which had fallen on to the floor.
He said: “It’s through sheer luck rather than judgment on your part that serious injury was not caused.
“You accept that you were distracted by trying to retrieve your bag. You do not dispute that you received and sent a WhatsApp message while driving on the approach to Kirkby station.
“In doing so you disregarded basic safety.”
Mr Polglase said the emergency brakes of the train were applied 18m (60ft) from the start of the platform.
The court heard Hollis, of Spellow Lane, Liverpool, had been a train driver since 1985 and was regarded as competent by his employers.
Patrick Williamson, defending, said Hollis had been diagnosed as suffering from post-traumatic stress disorder following the incident.
Mr Williamson said: “He, by virtue of this incident, was understandably and properly dismissed, bringing to an end a career of significant credit to him.
“It has been his life, in effect.”