What are some alternative functions in PHP that can be used instead of imap_fetch_overview for fetching email headers?

imap_fetchheader can be used as an alternative function to imap_fetch_overview for fetching email headers in PHP. This function retrieves the header of the message specified by msg_number in the current mailbox.

$hostname = '{imap.example.com:993/imap/ssl}INBOX';
$username = 'email@example.com';
$password = 'password';

$inbox = imap_open($hostname, $username, $password) or die('Cannot connect to mailbox: ' . imap_last_error());

$emails = imap_search($inbox, 'ALL');

foreach ($emails as $email_number) {
    $header = imap_fetchheader($inbox, $email_number);
    echo $header;
}

imap_close($inbox);