How can one ensure accurate retrieval of email parts using imap_fetchbody in PHP?

To ensure accurate retrieval of email parts using imap_fetchbody in PHP, it is important to specify the correct part number when calling the function. The part number corresponds to the MIME part of the email you want to retrieve, such as text/plain or text/html. By correctly identifying the part number, you can ensure that the desired email content is retrieved accurately.

<?php
// Connect to the IMAP server
$mailbox = imap_open('{mail.example.com:993/imap/ssl}INBOX', 'username', 'password');

// Retrieve the email body part (text/plain)
$email_body = imap_fetchbody($mailbox, $email_number, '1.1');

// Close the IMAP connection
imap_close($mailbox);
?>