A Massachusetts man pleaded guilty Wednesday to sending letters filled with white powder to President Trump’s sons and others.

Daniel Frisiello, 25, looked down and covered his mouth as the prosecutor, US Attorney Scott Garland, read the court some of his profanity- and slur-filled missives.

Frisiello was a “prolific letter writer,” Garland said, who penned notes to celebrities and public figures clamoring for autographs and sharing ideas — but who also had a “darker side.”

None of the substances sent in Frisiello’s threatening letters turned out to be hazardous.

Following Frisiello’s March arrest, his lawyer, William Fick, said his client would be pleading not guilty, but reversed course in court.

Among the letters Frisiello sent was one addressed to Donald Trump Jr. that his now-estranged wife, Vanessa, opened in February at the East 54th Street home of her mother, Bonnie Haydon. She had to be briefly hospitalized after reporting feeling nauseous and coughing.

The letter, postmarked from Boston, included a message to Trump Jr. that read: “You make the family idiot, Eric, look smart.”

“This is the reason why people hate you, so you are getting what you deserve,” the message said.

Frisiello also sent a white-powder letter to Eric Trump during the 2016 campaign, saying his dad must drop out of the race or the next note wouldn’t be fake.

With Post wires