The mother-in-law of an Iowa man posed as a teenage boy to catch her son-in-law soliciting photos from boys online after he had promised his wife he would stop doing so, prosecutors said.

The man, Ryan Mitchell Budde, 34, of Clinton, Iowa, was sentenced Nov. 12 to more than 10 years in prison for receiving and distributing child pornography, the U.S. Attorney for the Southern District of Iowa announced Wednesday. Budde pleaded guilty in July to one count of receiving and distributing child pornography.

Budde's wife became suspicious of his faithfulness and discovered that he had been talking with underage boys online and asking them for pictures, the assistant U.S. attorney prosecuting the case told NBC News Thursday. Budde promised to stop exchanging images and communicating with minors, but soon after, it was discovered that he continued this behavior.

"Budde’s mother-in-law took it upon herself to conduct an undercover investigation where she pretended to be a 15-year-old boy and began to communicate with Budde online," the assistant U.S. attorney said.

Within two weeks, Budde expressed an interest in meeting this "boy" for sex, according to the assistant U.S. attorney, who said this, among other things, led the couple to divorce and for Budde to lose parental rights.

The criminal investigation into Budde began in 2017 after law enforcement received a tip from Tumblr that he had uploaded 27 files containing child pornography to the social media site, the U.S. attorney’s statement said.

Two cellphones and two laptops belonging to Budde were seized and examined and 365 images were identified as child pornography and recovered from these devices, according to the U.S. attorney’s office.

"The investigation also revealed that Budde had chat sessions with young boys, where he pretended to be a 15 year-old virgin," the U.S. attorney’s office statement said. During these chats, Budde sent a picture of an erect penis, indicating it was a picture of himself, when in actuality, it was of another minor male, according to a sentencing document filed Nov. 6.

Budde admitted an “unhealthy attraction to teenaged boys," the sentencing document states. Budde told investigators he worked with boys as a volunteer with Big Brothers Big Sisters and at his church, leading a youth group.

"Budde systematically integrated himself in areas within the community wherein he would have access to teen boys," the sentencing document states. "Budde is a danger and the community needs to be protected."

Along with his 130-month prison sentence, Budde was also ordered to serve six years supervised release, pay $100 to the Crime Victim's Fund and $5,000 in restitution, and to adhere to sex-offender registry requirements upon release.