Open freescout-helpdesk opened 4 years ago
Very good point! Right now, it's not supported yet, unfortunately.
I've added a few functions in order to support OAuth, but I couldn't test it yet. It should later work like this:
// Create PhpImap\Mailbox instance for all further actions
$mailbox = new PhpImap\Mailbox(
'{imap.gmail.com:993/imap/ssl}INBOX', // IMAP server and mailbox folder
'some@gmail.com', // Username for the before configured mailbox
'*********', // Password for the before configured username
__DIR__, // Directory, where attachments will be saved (optional)
'UTF-8' // Server encoding (optional)
);
try {
$mailbox->setOAuthToken('TheOAuthAccessToken');
} catch (Exception $ex) {
die('Authentication using OAuth failed! Error: '.$ex->getMessage());
}
try {
$mailsIds = $mailbox->searchMailbox('ALL');
} catch(PhpImap\Exceptions\ConnectionException $ex) {
die('IMAP connection failed: '.$ex);
}
if(!$mailsIds) {
die('Mailbox is empty');
}
$mail = $mailbox->getMail($mailsIds[0]);
You can give it a try by using the develop
branch: git checkout develop
I'll try to implement a working and tested solution, but this will earliest happen next year due to the current holidays. Any help would be appreciated.
Useful references:
running automated testing for this would require changes mentioned in https://github.com/barbushin/php-imap/issues/432#issuecomment-578825685, or finding an IMAP-enabled mail provider that supports automated account creation w/ oauth imap so the account can be created & deleted on each travis build.
Please forgive me asking, but are there any updates on this? It would be so helpful to have OAuth support for e.g. GMail/Google Workspace, and Microsoft Office 365 mail accounts.
I'm willing to help / do the implementation, what is the current status?
There are no updates yet.
I've tried to work and implement it some time ago, so the current progress is available in the respective branch: 411-OAuth-Support
Feel free to submit your own pull request or add commits to the existing one.
Hi! @freescout-helpdesk @Sebi94nbg @hrst @bapcltd-marv @rmontagud
The strategy to overcome the problem is replacing all the imap_*
functions with the equivalent imap2_*
imap_open(...)
become imap2_open(...)
imap_getmailboxes(...)
become imap2_getmailboxes(...)
etc...
The idea behind the imap2 library is to replace the core php imap extension with a new one written in PHP. Why? We have problem with the UW-IMAP https://github.com/uw-imap/imap it seem outdate from 2019. There are many security concerns about it
I'm waiting from your feedback! I hope that imap2 is a good replacement for imap
cc @millnet-maho
Just a heads-up to everyone: Microsoft will disable Basic Auth on Oct 1st, 2022. In contrast to Google, "App Passwords" will not be possible/allowed, only OAuth2.
Status for PHP imap_* extension (page not updated since 2020 as of writing this): https://wiki.php.net/todo/ext/imap/xoauth2
When we plan to add support for oAuth to this package?
is there any plan to support oAuth? because Microsoft will disable Basic Auth in Januar 2023 look here: https://techcommunity.microsoft.com/t5/exchange-team-blog/basic-authentication-deprecation-in-exchange-online-september/ba-p/3609437
Hello, as a workaround is there maybe the possibility to login using another library, like https://www.php-imap.com/ that does support oauth and then pass the object in some way to keep working with this php-imap library? We built a whole app using this library and we would do anything to avoid rewriting everything... Thanks!
Hello everyone, back in 2019 I already worked on the OAuth support, but I had no chance to test it.
These changes are still on the 411-OAuth-Support
branch, so if somebody could test it and provide feedback, it would be great.
Pull requests by other people are also welcome.
Since christmas time is coming soon and I'm also currently working on some other projects, I can't gurantee, that I can finish this implementation until end of December 2022. However, I'll try my best to get it done.
has anyone be able to get this to work correctly I am trying to update for Outlook update.
hi everyone, any news about OAuth-Support? we got today the "Exchange Online Basic Auth Deprecation – 7 Day Notice" in Office 365 Center
Approximately 7 days from today, we’re going to permanently disable basic authentication for the following Exchange Online protocols: MAPI, RPC, Offline Address Book, Exchange Web Services, POP, IMAP, Exchange ActiveSync and Remote PowerShell.
within the next 7 days basic auth will be deactivated, so we need a solution soon....
@barbushin any plan to manage OAUTH?
Same here
Is Google OAuth authentication supported in this library? https://github.com/google/gmail-oauth2-tools/issues/18