The 39-year-old singer confirmed in an interview with the New York Times that his single "Still Feel Like Your Man" was written about Perry.
"Who else would I be thinking about?" he said. "And by the way, it's a testament to the fact that I have not dated a lot of people in the past five, six years. That was my only relationship. So it's like, give me this, people."
Mayer and Perry split in 2015 after three years of on-again, off-again dating, but have remained friendly since. The pair both attended Drake's 30th birthday party in October.
"[They] spoke throughout the night [very] peacefully," a source told E! News at the time.
Mayer has also dated Jessica Simpson, Jennifer Aniston and Taylor Swift, while Perry split from Orlando Bloom in February. Mayer said on The Ellen DeGeneres Show the same month that he doesn't think he'd find love on The Bachelor.
"I think it'd be really fun," he said before qualifying, "I don't think that I would find love there, unless they would change the sort of vetting process for who would be the contestants."
"Still Feel Like Your Man" appears on Mayer's EP The Search for Everything: Wave Two. He will release a full-length studio album, The Search for Everything, with the song on April 14.