The feds on Thursday busted a 24-year-old nutcase from suburban Boston for allegedly sending threatening letters containing a white powder — including one to Donald Trump Jr. last month that landed his wife in the hospital.

Daniel Frisiello of Beverly left a lengthy trail of clues that enabled the Boston Joint Terrorism Task Force to identify him and track him down just weeks after the letter to Trump Jr. arrived at his mother-in-law’s Upper East Side pad on Feb. 12.

The letter was postmarked from Boston on Feb. 7, and the first son’s frightened wife Vanessa was briefly hospitalized when she opened it and started coughing and feeling nauseous.

“You are an awful, awful person,” the note said. “I am surprised that your father lets you speak on TV. You make the family idiot, Eric, look smart.

This is the reason why people hate you, so you are getting what you deserve. So shut the f–k UP!”

Frisiello — who shouts “God Save the Queen! on his cellphone voicemail message and posts tributes to the UK’s Royal Family on his Facebook page — also sent “glitter bombs” to at least one of the people he also sent white powder to, the feds said.

“Pay us money, provide an address [and] we’ll send your recipient so much glitter in an envelope that they’ll be finding it everywhere for weeks,” their website said, though it could not be accessed Thursday afternoon.

But Frisiello paid for the glitter bomb with a debit or credit card issued by TD Bank in his name, and the company turned over his information to investigators, who quickly identified him.

Scrutinizing his other financial transactions, they also learned that he had bought stamps and paper, envelopes and stamps that matched those used in the threatening letters.

The feds — including FBI agents and US Postal Service inspectors — launched a surveillance operation at the suspect’s home at 62 Hathaway Ave. in Beverly, about 15 miles northeast of Boston.

They also searched Frisiello’s trash, where they found remnants of the same paper as well as a CVS receipt for the purchases.

They obtained a search warrant and team of agents in four vehicles raided his family’s home at about 8 a.m. Thursday.

Neighbors told salemnews.com that they heard a loud explosion that caused power on the street to go out and minutes later the feds arrived in force.

About a minute later, at least four vehicles came down the street and went to 62 Hathaway.

“I heard a big explosion and then these guys came rolling up,” Richard Faille, who lives across the street, told the website.

Frisiello was arrested on federal charges of mailing threats to injure and providing false information and hoaxes, according to the Massachusetts US Attorney’s Office.