I am using the Tmail library, and for each attachment in an email, when I do attachment.content_type, sometimes I get not just the content type
If image/jpeg; name=example3.jpg is a String:
("image/jpeg; name=example3.jpg".split("; ") & VALID_CONTENT_TYPES).length > 0
i.e. intersection (elements common to the two arrays) of VALID_CONTENT_TYPES array and attachment.content_type array (including type) should be greater than 0.
That's at least one of many ways.