Hi. Foaming is definitely concerning! Does he chew on plants or other objects in the house or been exposed to any topical flea products or household solutions recently? Sometimes cats will foam if they experience a bad taste, a food they don't like, chewing on electrical cords or batteries etc. If possible check the mouth for any burns, injuries, ulcerations or anything that looks different. Remove any items that may have induced the problem Watch for any vomiting and/or diarrhea. Make sure he continues to eat and act normal. If the foaming stops, then I believe there is nothing to worry about. If the foaming is persistent have your veterinary evaluate him.
Great! I'm glad to hear that the foaming stopped. The veggies could have had something to do with it. Even just licking the skin of some veggies, especially if they have not been washed yet, could possible have an unpleasant taste for a cat. Sometimes even licking or rubbing the mouth against a surface or furniture that has recently been cleaned could result in a bad taste in the mouth that will cause a cat to foam. I hope he continues to do well!