Swansea magistrates said Robert Riley's online messages were also racially and religiously aggravated and that only a custodial sentence could be imposed.
Riley, from Port Talbot, was sentenced to eight weeks in custody after admitting posting an abusive Twitter message about the death of Leeds schoolteacher Ann Maguire.
The 42-year-old was the second person to be charged with the offence in the wake of the death of Mrs Maguire, who was stabbed to death in her classroom at Corpus Christi Catholic College last month.
Yesterday a third person was arrested in Cardiff and bailed.
More top news
A few showers at times but there'll be clear skies which will allow temperatures to tumble, which in turn means we'll see frost and ice!
From makeup to mechanics, video bloggers - or 'vloggers' - are broadcasting their knowledge to millions of eager consumers across the globe.
It's Christmas Jumper Day and Dyfed-Powys Police has dealt with a man caught stealing two Christmas jumpers.