Thomas Davis, a 48-year-old man from Mashpee, Mass., had been sending messages and nude photos to an undercover agent he believed to be a 14-year-old girl, and asked the girl to send him nude photos in return, authorities said.