A Massachusetts man accused of sending racist and threatening emails to Philadelphia Police Commissioner Danielle Outlaw this month will be jailed until trial because of a history of making alcohol-fueled threats against law enforcement and public officials, a federal judge ruled Tuesday.

Peter Fratus, 39, of West Dennis, bowed his head and put his hands over his face as U.S. Magistrate Judge David H. Hennessy announced his decision during a Zoom hearing. Hennessy said Fratus, who struggles with alcoholism, has repeatedly lashed out at people while under the influence, including in 2019, when he kicked two police officers at a store, screamed obscenities at them, and threatened to kill them, according to court documents.

Fratus, who is white, was on probation in that incident on June 6, when he allegedly sent two emails laced with racial epithets to Outlaw, the first black woman to lead Philadelphia’s police department.

Prosecutors have not said why he decided to email Outlaw. Hennessy called Fratus’ alleged messages “offensive and disgusting,” and said his history of similar behavior over a decade showed that releasing him before trial could allow him to continue drinking and threatening people.

“At some point in everyone’s life, we all have to be accountable [for] issues we need to deal with,” Hennessy said. “This defendant has a strong history in alcoholism that should point him in the direction he needs to go.”

In their motion arguing to keep him detained, prosecutors accused Fratus of menacing or violent behavior in seven instances dating to 2005, including leaving a racist voicemail for an African American congresswoman, leaving two racist voicemails at an Islamic cultural center, calling a Palestinian American businessman a terrorist, punching and kicking a man experiencing homelessness in Boston, beating up his African American girlfriend, and assaulting a transit worker who confronted him about not paying his train fare.

Fratus’ attorney, Brendan Kelley, said Fratus had a difficult upbringing and has long struggled with alcoholism, acknowledging: “When he’s drunk, he says vile and disgusting things, and there’s no excuse for that.”

Kelley asked Hennessy to consider house arrest paired with strict monitoring for alcohol consumption, a request the judge quickly denied.

“How do you monitor somebody at midnight, at 2 a.m., at 4 a.m., short of putting a probation officer in the house with a defendant to ensure he doesn’t drink?” Hennessy said.

It was not immediately clear when Fratus was next due in court. He is expected to be transferred to the Philadelphia Federal Detention Center within the next few weeks.

If he is convicted of sending threatening interstate communications, he faces a maximum prison sentence of five years.