Getting the text of a gmail body only when attachment is present PHP IMAP

I have some working IMAP php code that gets the subject, from, to, and other headers. However, if the email has an attachment (pdf in this case) when I try to get the text of the email (i.e. “Dear so and so, please find attahced …”) all I get is 50,000 random characters, which is the attachement, and not the text in the body of the email.

In the classic form of the universe, the one thing you definitely want is inaccessible, but the thing you don’t works like a charm 😉

When I copy the text of the body and send an email w/o any attachment, I can get the text of the body. But as long as the attachment is present, I can’t

After spending too much time trying to figure this out, I came across imap_fetchbody, and these alleged conditions that are ‘supposed’ to work, like 1, 1.1, 1.2, 2, 2.1, etc

$  message = quoted_printable_decode(imap_fetchbody($  inbox, $  email_number,1.1));  $  message = quoted_printable_decode(imap_fetchbody($  inbox, $  email_number,1.2));  $  message = quoted_printable_decode(imap_fetchbody($  inbox, $  email_number,1.3));  $  message = quoted_printable_decode(imap_fetchbody($  inbox, $  email_number,2));  $  message = quoted_printable_decode(imap_fetchbody($  inbox, $  email_number,2.1));  $  message = quoted_printable_decode(imap_fetchbody($  inbox, $  email_number,2.2)); 

My code throws no errors, it just can’t get the body of the email when there is an attachment