Foul odor from the mouth could be caused by several problems. Most commonly however, it originates from some type of dental problem.
Horses are predisposed to having the same dental problems that humans do. This includes gum disease, broken teeth, cavities, and food packing in between teeth. In addition to those abnormalities that we can relate to, horses can also have severe overgrowths in the crown of their teeth or conversely worn teeth that are short with minimal grinding surface. In most of these cases packed feed material decomposes and bacteria invades the soft tissues of the mouth causing a foul odor.
I would recommend examination of the mouth under sedation with a full mouth speculum. Dental tools such as a mirror and dental picks are typically required to find some of these problems.