A Massachusetts man who sent racist and threatening emails to Police Commissioner Danielle Outlaw at the height of the 2020 racial injustice protests was sentenced Wednesday to four years in federal prison.

Peter Fratus, 40, told U.S. District Judge Gerald J. Pappert that he was blackout drunk when he sent the messages — which alluded to lynching Black people and contained anti-Semitic slurs — and that he had no recollection of writing them. He had struggled with alcoholism for years, he said, and often became violent when drunk.

“While we all say things that at times we regret, my words were not simply regretful — they were malicious, obscene, repulsive … cowardly, and the list goes on,” Fratus added. “They were racist, plain and simple.”

But Pappert noted that Fratus’ violent outburst in June 2020 wasn’t the first time he’d threatened officers and cited his more than decade-long record of drinking heavily, hurling slurs, and fighting with police and others in his hometown.

In 2011, Fratus was arrested for randomly attacking a Black woman on the street. He punched her multiple times, kicked her in the back, and pulled out her hair extensions.

He assaulted a homeless person while yelling racial slurs in 2015. A year later, he threatened a Palestinian American businessman, calling him a “terrorist,” and then began shoving customers in his store.

Threats he made in 2018 against Rep. Maxine Waters (D., Calif.) — including about lynching Black members of Congress — drew FBI scrutiny.

By the time he contacted Outlaw, Fratus was under investigation by the Massachusetts State Police for leaving menacing voice mails in which he threatened to slit the throat of the state’s attorney general, Maura Healey. And he was also still on probation for a 2019 incident in which he wiped his bloodied hands at a Christmas tree store then fought and threatened to rape and kill the officers who eventually placed him under arrest.

“He’s a ticking time bomb, and when he explodes, he will take with him whomever is unlucky enough to be standing nearby,” wrote Assistant U.S. Attorney Robert J. Livermore in court papers before Wednesday’s hearing. “He hates himself, his life, and his world so much that no amount of punishment could possibly deter him from being himself.”

Fratus, who sat slump-shouldered with his head bowed next to his lawyer throughout Wednesday’s hearing, didn’t disagree.

“He’s not a racist,” his mother, Elizabeth Faiella, told the court. “But when he’s in a blackout he hates Jews … he hates Muslims. It’s a terrible disease.”

When it came time for Fratus to address the judge, he referred to himself as a “human piece of excrement” and said his chronic alcoholism — a condition he fueled by drinking a liter-and-a-half of vodka a day — turned him into “Dr. Jekyll and Mr. Hyde.”

By the time he was arrested, he said, “there wasn’t even much of a Dr. Jekyll left.”

He said he’d been dissatisfied with the direction of the country in June 2020 and had been watching news reports of the unrest in Philadelphia from his Cape Cod home. He searched Outlaw’s name on the internet several times in the minutes before he contacted her.

She’d been named the first Black woman to lead the 6,000-member police force only months before and her efforts to lead the department through that spring’s protests over the police killing of George Floyd in Minneapolis had increased her national profile.

FBI agents arrested him within two weeks and he’s been held in custody, due to those earlier violent encounters with police, ever since.

In prison, Fratus accepted treatment for his addiction for the first time and said he has achieved 18 months of sobriety — a condition he vowed on Wednesday to maintain for the rest of his life.

“Some people just cannot drink — ever — and I am one of them,” he said. “I hope to live the rest of my life in a manner Commissioner Outlaw would be proud of — and I hope one day she can forgive me.”