A secret sexual relationship between a female PE teacher and a 15-year-old pupil at a private all-girls’ school was only discovered because of a faulty printer, it has emerged.

Emily Fox, who taught PE at the Royal Masonic School for Girls in Rickmansworth, Hertfordshire, was jailed for 15 months for engaging in sexual activity with a child while in a position of trust on Friday.

The 26-year-old teacher exchanged hundreds of “sexually explicit” messages with the girl, the court heard, but the relationship did not come to light until the teenager attempted to print one of the emails out.

Sally Mealing-McLeod, acting for the prosecution, told St Albans Crown Court the revealing message was inadvertently seen by her parents, who alerted authorities in August last year.

She said the girl sent the email to the faulty machine and when it failed to print she thought nothing of it.

“A week later the father was using the printer when that particular document was printed,” Ms Mealing-McLeod added.

He failed to notice its contents at first but it was then read by his wife.

“That clearly disclosed some sort of relationship," she added.

"As a result the mother contacted the school and spoke to the headmistress."

After the email printed out, the pair exchanged messages trying to work out how to "cover up" the relationship, the court heard, and when spoken to by police, the victim at first denied any relationship before disclosing it at a second visit.

A “friendship” began between Fox and the pupil, who cannot be named for legal reasons, started in November 2012 and became more intense around Easter 2013.

"It began with kissing one another [...] and then, a little later on, turned into more of a sexual relationship," Ms Mealing-McLeod said.

Fox voluntarily handed herself in to Hatfield police station in September last year after Hertfordshire Constabulary started investigating and later pleaded guilty to four counts of engaging in sexual activity with a child while in a position of trust.

She had been working at the Royal Masonic School for Girls, which charges up to £25,000 a year, since 2010 and her representatives said Fox's “cherished” career had been ruined.

Her barrister, Dee Connelly, said the teacher felt "remorse and contrition" and urged the judge to take into account that the age gap between the two was "not that great".

As he passed sentence on Friday, Judge Stephen Gullick said the sexual relationship lasted three or four months and he had no doubt she was a "gifted and well-loved" teacher.

He added: "In my judgment, you were always aware that the relationship was not only wrong but also unlawful."

The judge stressed that "this type of behaviour towards pupils by teachers" must be seen as "extremely grave".