A text message saved Japanese exchange student from further sexual abuse from her host after he groped her as they watched a movie.
Police are praising the 15-year-old's actions after she fled 46-year-old Philippe Masei and locked herself in the toilet before messaging her classmates for help.
A fellow student then alerted her host family, who called the police.
The victim had been in New Zealand for just six hours and briefly met her host family, which included Masei, before the offending occurred.
Masei was in the Hamilton District Court for sentencing yesterday after being found guilty in March on a charge of indecent assault.
The incident happened in July 2014 and the victim and her classmates were taking part in a Waikato University English exchange programme that involved them being billeted out to get a Kiwi experience.
That night, Masei's wife had to attend a church meeting so she left him in charge of their young children as well as the victim. Masei organised them all to watch a movie, putting a mattress on the floor in the lounge and turning the lights out. Shortly afterwards, he told his two young daughters to go into the kitchen.
He then asked the victim "to make a secret" and began touching her "all over her body" and trying to take her clothes off.
Judge Robert Spear said the victim, with her limited English, tried "as best she could" to tell him not to touch her.
"You continued and she then said that she had a stomach ache and had to go to the toilet."
When in the toilet she made contact with her classmates, using a social media messaging service, asking them to help her. One of her fellow students then told her host mother, who called police. Officers arrived about 20 minutes later.
Judge Spear said Masei had tried to persuade the girl to come out of the toilet, saying one of his young daughters needed to go.
"She was heavily traumatised by this experience and of course it ruined her trip to New Zealand."
The victim had since changed her study options to ones that did not include studying abroad.
Masei's lawyer, Tom Sutcliffe, said his client was now "extremely remorseful" and had written a letter of apology to the court.
"What he does need is some help, to help him understand that he obviously has a character weakness, a flaw, that has led him to engage in this activity."
He had lost not only his job but it also caused the break-up of his family, he said.
However, in sentencing Masei to 21 months' prison, Judge Spear dismissed his apology, stating nothing less than jail would be appropriate.
"I do not consider that you are genuinely remorseful ... this was appalling behaviour on your part because not only did it involve you, a 46-year-old man, a family man, indecently assaulting a 15-year-old girl, but the victim in this case was one who was especially vulnerable. She was in a foreign country. She was separated from anyone she knew."
Masei's wife said she was focusing on bringing up their two daughters and moving on with their lives.
The officer in charge of the case, Detective Mike Handley of Waikato police, praised the victim's "quick-thinking" actions by getting out of the situation, grabbing her phone, and locking herself in the toilet.
"The actions of this vulnerable, young foreign student are admirable and her bravery is to be recognised. She was quick-thinking in real difficult circumstances in a foreign land and with people she had only just met ... she was in the country six hours and within a couple of hours he has offended against her."
Mr Handley said the messaging service had been set up by the victim's school in Japan before the students arrived in New Zealand.