A Twitter troll who delighted in the fatal stabbing of teacher Ann Maguire has been jailed for eight weeks.
In the wake of Mrs Maguire's death, Robert Riley bragged to his followers he would not just have killed Mrs Maguire but "all the bastard teachers" at Corpus Christi School in Leeds.
The jobless 42-year-old from Cwmavon, Port Talbot, also posted a series of racist tweets claiming Nazi death camp Auschwitz was a "health spa" and suggesting that Muslim babies should be drowned.
Despite a Twitter backlash, Riley, who used the handle @johnriley001, initially revelled in his new found notoriety, boasting that he had the "biggest gob this side of the River Severn".
However, the ex-junkie cut a more forlorn figure when appeared before Swansea magistrates today.
After pleading guilty to one charge of sending a grossly offensive message via a public communications network, Riley begged for leniency.
However, chairwoman of the bench Georgina Scannell voiced her disgust and said she was left with no choice but to send the defendant straight to jail.
She said: "The offensive messages outraged the public. You had complete disregard for the tragic death of Ann Maguire.
"Besides this, countless other vile messages were made by you.
"T he bench finds these were racially and religious aggravated.
"The offences are so serious that only a period of immediate custody can be justified."
Mrs Maguire was stabbed while teaching a lesson at her school on April 28.
Despite widespread shock and sadness at her death, two days later Riley saw fit to make fun of the tragedy.
And he remained incredulous following a backlash from other Twitter users, saying: "Of all the sick things I've tweeted, starvation, genocide, rape and torture, it's the teacher from Leeds that outrages everyone the most."
Prosecutor Linda Baker told the court that following a complaint to police, the defendant's other offensive tweets came to light.
Among them were messages about the missing Malaysian plane, the Korean ferry disaster and champion tennis player Serena Williams.
The court heard that at the time, Riley was subject to an existing community order for an unrelated offence.
His solicitor, Giles Hayes, said Riley, a former bus driver who left school aged 15 with no qualifications, lived an insular life.
Mr Hayes said of the tweet about Mrs Maguire: "It's a senseless act at a very sensitive time."
The court also heard a report from the Probation Service saying that Riley was a full time carer for a 44- year-old woman.
"Because of this he has very little time for social activity out of the house," it said.
Riley regarded Twitter as a chance to engage in "social banter" but had "no idea" of the site's "vastness".
Since his arrest the defendant - who was previously jailed for 12 weeks in 2012 - has sought help from counsellors over anger management issues relating to a "mental nature".
His legal team admitted while his offensive comments pushed Riley past the custody threshold, the court could still impose a suspended sentence.
Mr Hayes said that would give the defendant the chance and the support to address his behavioural problems.
However, magistrates decided otherwise and Riley - dressed in a black shirt and trousers - was led down to the cells by two female security officers.
He hid his face as he was then led into a custody van and driven to prison.
Riley is the second person to be charged with the offence in the wake of Mrs Maguire's death.
Jake Newsome, 21, from the Harehills area of Leeds, was released on bail after being charged for the alleged abuse, police said.
He is due to appear before Leeds Magistrates' Court on May 14.
West Yorkshire Police said a 16-year-old Cardiff boy had been arrested by police on Wednesday following complaints and bailed pending a psychiatric assessment. A 15-year-old boy, who cannot be identified for legal reasons, has been charged with Mrs Maguire's murder and is due to stand trial in November.