From 4e95e6633e4755a8b0256d4013ae5c8a6ca5f34e Mon Sep 17 00:00:00 2001 From: Pierre Grimaud Date: Sun, 13 Sep 2020 16:52:16 +0200 Subject: [PATCH] Fix outlook email auth (#127) --- src/Instagram/Auth/Checkpoint/ImapClient.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Instagram/Auth/Checkpoint/ImapClient.php b/src/Instagram/Auth/Checkpoint/ImapClient.php index 1c2dcb3..6e55f97 100644 --- a/src/Instagram/Auth/Checkpoint/ImapClient.php +++ b/src/Instagram/Auth/Checkpoint/ImapClient.php @@ -117,7 +117,19 @@ public function getLastInstagramEmailContent(int $try = 1): string $headers = imap_headerinfo($resource, $i, 0); preg_match('/([0-9]{6})<\/font>/s', $body, $match); - if ($headers->senderaddress === 'Instagram ' && isset($match[1])) { + + $isMailFromInstagram = false; + + // confirm instagram is the mail sender + if ( + (property_exists($headers, 'senderaddress') && + $headers->senderaddress === 'Instagram ') + || $headers->from->host === 'mail.instagram.com' + ) { + $isMailFromInstagram = true; + } + + if ($isMailFromInstagram && isset($match[1])) { imap_delete($resource, $i); $foundCode = true;