A New York man who confessed to cyberstalking his ex-girlfriend, posting her personal information on a prostitution site and mailing her drugs at college in an attempt to get her arrested, was sentenced to four years in prison on Wednesday.

Thomas Traficante, 23, of Seaford, was convicted of “cyberstalking and distribution of a controlled substance” after US District Judge David Larimer found Traficante’s actions “despicable,” the Democrat & Chronicle reported.

“If you had a modicum of intelligence, you should know that what you did, repeatedly, was despicable,” Larimer said.

Raymond Perini, Traficante’s lawyer, said they planned to appeal the sentencing. In March, Traficante pleaded guilty to cyberstalking and distribution of a controlled substance.

Traficante, a student at St. John’s University in Queens, met his former girlfriend, a SUNY Geneseo student who was not identified, through an online dating website. The two broke up on Oct. 26, 2017.

The spurned lover then started sending his ex-girlfriend and her sorority sisters cryptic text messages telling them “it’s not safe out there tonight” and “there are various people among different orgs who have me. My plan is to hurt them,” prosecutors said.

At one point, Traficante reportedly used a device to alter his voice, telling the woman’s roommates “I’m in the house.” The woman changed her cellphone number, but Traficante was able to find the new one and threaten her further, prosecutors said.

In November, Traficante mailed the woman drugs, including cocaine and methamphetamines, to her college mailbox. He then notified police about the drugs in order to set up the woman.

Newsday reported the woman’s room was searched but nothing was found. The victim told officers her ex-boyfriend was “controlling.” She also showed officers texts from Traficante in which he threatened to share her personal information on a prostitution site if “she did something he strongly disagreed with.”

The Democrat & Chronicle reported Traficante posted the woman’s information on Backpage.com, under a prostitution category, and she received some 60 calls from men asking for sex. She also said her former boyfriend hacked into her Amazon account and sent her a book titled “I’m Watching You.” He also allegedly hacked into her email, cellphone and social media accounts.

The woman also claimed Traficante gained access to her school account and took quizzes under her name, purposely getting her a failing grade. Traficante was also accused of shooting the victim’s parents’ home with a BB gun.

When police arrested him at his mother’s home in December 2017, a loaded AR-15 rifle was found. It was not immediately clear if Traficante had purchased the gun legally. Traficante was enrolled in a master’s degree program at the time of his arrest.

Traficante’s victim was in the courtroom on Wednesday. Assistant US Attorney Melissa Marangola said the woman was thinking of changing her name after what she endured.

Traficante has been accused of stalking previously. From 2014 to 2015, another woman claimed she was cyberstalked by Traficante, but he was not charged in that case.