Search code examples
phpgmailimap

PHP IMAP - Get Message ID in gmail


I've sent myself an email (from outlook to gmail), and if I click show original in gmail I can see the following:

message id

However when I run the following in PHP:

print_r(imap_fetchheader($inbox,$email_number));

The message ID is missing:

Subject: Test
Thread-Topic: Test
Thread-Index: AQHUppuI1MuEEl1ubE+/5eFPvzB8RQ==
Date: Mon, 7 Jan 2019 15:13:23 +0000
Message-ID: 
Accept-Language: en-GB, en-US
Content-Language: en-GB

Does gmail hide this information from PHP IMAP or am I missing something?


Solution

  • If you're showing it in a web browser, your Message-ID is surrounded by < and >, so it is may be interpreted as a tag. You may need to escape it.