The 26-year-old, who had pleaded guilty to two counts of unauthorized access to computers in April, has been sentenced to five years in prison.

American prosecutor Jason Y. Storr told reporters after the hearing that the hacker had broken into the emails of royal weddings and subsequent pregnancies.

He said in a statement that Middleton’s grandfather, James Middleton, had visited her in hospital the night before he died. The father had taken photos of Kate, Duchess of Cambridge’s four children and rearranged their nappies.

Yusef Jabar Jabar, 31, hacked into the emails of Pippa Middleton, her mother and former partner James Matthews. The 26-year-old, who had pleaded guilty to two counts of unauthorized access to computers in April, has been sentenced to five years in prison.

The father, whose father was a junior member of the royal family, pleaded guilty in April to hacking into some emails belonging to the former girlfriend of his son-in-law and other people and then posting them online.

Jabar Jabar, 31, hacked into the emails of Pippa Middleton, her mother and former partner James Matthews.

The defendant, from Coventry, appeared in a blue sweatshirt and red trainers at London’s Old Bailey courtroom.

By LORNE GUNTER