Margaret Smith, president of the Scottish Secondary Teachers' Association, spoke out about the "sinister development" of young people using social networking websites and mobile phones to target teachers.
This could see staff subjected to verbal abuse, threats and ridicule, with females "often subjected to grossly offensive comments regarding their personal lives which can be deemed nothing other than sexual harassment", she said.
"Too often nothing is done and pupils believe their conduct is without consequence," she added.
While the union leader accepted classroom indiscipline was "not a uniquely Scottish problem", she said most European countries "call for a co-ordinated approach to indiscipline and see tackling it as part of the duty of care employers have towards employees".
But, said Ms Smith, "this was rarely the situation in Scotland".
Teacher stress levels are "at an all-time high" but tackling bad behaviour in the classroom would reduce this, Ms Smith added.
A Scottish Government spokesman said: "The vast majority of pupils in our schools are well behaved. However, we are working to improve behaviour.
"Independent research shows that behaviour, including serious indiscipline and violence, has improved since 2006."