Despite being confronted by a backlash from other Twitter users, Riley initially revelled in his new found notoriety, and boasted that he had the "biggest gob this side of the River Severn".
Riley pled guilty at Swansea magistrates to one charge of sending a grossly offensive message via a public communications network.
Chairwoman of the bench Georgina Scannell voiced 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.
"The bench finds these were racially and religious aggravated.
"The offences are so serious that only a period of immediate custody can be justified."
- The Independent