Search code examples
phpemailoutlookimap

Accessing my outlook inbox via php code


How i can access my outlook account through my php code? I need to get the subject, from address and attachment. And then i need to mark the accessed as read on outlook. I have already accessed gmail account using IMAP but now i want to access outlook account.

Is it possible?

Any help will be appreciated.


Solution

  • ALERT DEPRECATED code: https://learn.microsoft.com/en-us/exchange/clients-and-mobile-in-exchange-online/deprecation-of-basic-authentication-exchange-online

    ==================

    Finally i got a solution, i can access the outlook account using IMAP in PHP.

    $hostname = '{outlook.office365.com:993/imap/ssl/novalidate-cert}INBOX';
        $username = 'username';
        $password = 'password'; 
    
    /* try to connect */
    $inbox = imap_open($hostname,$username,$password) or die('Cannot connect to '.$hostname.': ' . imap_last_error());