To get the HTML content of an email using PHP IMAP, you can use the imap_fetchbody function. Here's an example:
// Connect to the mailbox
$imap = imap_open('{imap.example.com:993/imap/ssl}INBOX', 'username', 'password');
// Get the message ID of the email you want to fetch
$messageId = 123;
// Fetch the HTML content of the email
$html = imap_fetchbody($imap, $messageId, '1.2');
// Close the mailbox connection
imap_close($imap);
In the above example, 1.2 is the MIME part number of the HTML content. You can find the MIME part number by using the imap_fetchstructure function.
To get the last thread of a forwarded email as HTML text, you can use the imap_fetchtext function. Here's an example:
// Connect to the mailbox
$imap = imap_open('{imap.example.com:993/imap/ssl}INBOX', 'username', 'password');
// Get the message ID of the email you want to fetch
$messageId = 123;
// Fetch the last thread of the forwarded email as HTML text
$html = imap_fetchtext($imap, $messageId, FT_UID | FT_PEEK);
// Close the mailbox connection
imap_close($imap);
In the above example, FT_UID and FT_PEEK are options that tell the imap_fetchtext function to fetch the email by UID (unique identifier) and to not mark the email as read, respectively.