The notion of recycling these gadgets sounds virtuous: an infinite loop of technological utility.

But it is dirty and dangerous work to extract the tiny quantities of precious metals — like gold, silver and copper — from castoff phones, computers and televisions.

For years, China took in much of the world’s electronic refuse. Then in 2018, Beijing closed its borders to foreign e-waste. Thailand and other countries in Southeast Asia — with their lax enforcement of environmental laws, easily exploited labor force and cozy nexus between business and government — saw an opportunity.

“Every circuit and every cable is very lucrative, especially if there is no concern for the environment or for workers,” said Penchom Saetang, the head of Ecological Alert and Recovery Thailand, an environmental watchdog.

While Southeast Asian nations like Indonesia, Malaysia and the Philippines have rejected individual shipments of waste from Western countries, Thailand was the first to push back more systematically against the electronic refuse deluging its ports.

In June of last year, the Thai Ministry of Industry announced with great fanfare the ban on foreign e-waste. The police made a series of high-profile raids on at least 10 factories, including New Sky Metal.

“New Sky is closed now, totally closed,” Yutthana Poolpipat, the head of the Laem Chabang Port customs bureau, said in September. “There is no electronic waste coming into Thailand, zero.”

But a recent visit to the hamlet of Koh Khanun showed that the factory was still up and running, as are many others, a reflection of the weak regulatory system and corruption that has tainted the country.