A woman who tried to frame her husband by texting death threats to herself from his mobile has been given a two- year community rehabilitation order.
The judge said Jennifer Harris was lucky not to go to jail
Jennifer Harris, 52, took a SIM card from her estranged husband's old phone and sent the threats to her own mobile.
Her husband was later arrested on suspicion of making threats to kill.
Harris, from Barry, admitted attempting to pervert the course of justice. The judge at Cardiff Crown Court said she must agree to medical treatment.
When she appeared at Cardiff Crown Court in February, the jury was told the mother of two had hatched the texting plan when she and husband David Harris, also 52, were going through a bitter divorce after 28 years.
She had driven from their former home to his new home six miles away with his old SIM card - the unique chip which gives a mobile its identity.
The court heard Harris, who worked at a delicatessen, sat near his house so that the signal could be traced to his address.
She put the card into her own phone and sent four texts to her own mobile. One message warned: "You'll be looking over your shoulder for the rest of your life."
Later she showed the messages to police and they arrested her husband on suspicion of making threats to kill.
Mr Harris had always denied making the threats.
Mobile phone company Orange later had checked its records and was able to prove the threatening texts had been sent using Mrs Harris's handset, the court was told.
When Harris pleaded guilty to trying to pervert the course of justice, her barrister James Cranfield told the court that his client had a long history of health problems.
Sentencing was adjourned reports to be compiled.
Judge Phillip Richards, also sitting at Cardiff Crown Court, told her on Wednesday that it was a "very serious offence" and she was lucky not to be going to prison.
He said: "It is quite plain that a wholly innocent man was made the subject of allegations.
"When relationships break up there can be bitterness and that bitterness can lead people to behaving in a way they would not normally behave."
Outside court, Mr Harris, who is now engaged to be married again, spoke of his relief that the case was over.
The director of a commercial vehicle repair workshop said: "I'm sad that things have ended up this way between Jennifer and I, especially for the kids, but I just want to put it all behind me now."