Emailcollectors with Microsoft 365 Oauth2

Hi,
i am using 17.0.1 and have managed to use IMAP collect with Microsoft 365 oauth2, but i have trouble with the emailcollector, my cron job has 3 jobs which are being processed every 5 minutes, but it collects only from the last cron job, for example, the following picture is the way it works with normal imap on strato, all jobs ran fine 11:23, when i change to outlook.office365.com with oauth2 token, i can manually collect just fine, but the cron job only collects the last one “Collect_Ticket_Request”, if i deactivate “Collect_Ticket_Request” then the “Collect_Response_Out” is the only working job.

PS
I had to change two files to get oauth2 with microsoft to work,

/var/www/dolibarr/htdocs/includes/OAuth/OAuth2/Service/Microsoft.php
/var/www/dolibarr/htdocs/core/lib/oauth.lib.php
the scopes needed to be changed from

https ://outlook.office365.com
to
https ://outlook.office.com

1 Like

Thanks for feedback about oauth2 fix.
Can you confirm this 2 sentences :

  • If you use https ://outlook.offic.com instead of https ://outlook.office365.com into the 2 mentionned files, the collect work manually for the 3 jobs. But only last when ran by cron, right or wrong ?

  • If you keep outlook.office365.com, no jobs works, even when ran manually, right or wrong ?

Hi,
1st - right i confirm -
2nd - not any more - i made a fresh test installation, now both address work outlook.office.com also outlook.office365.com

testet with 17.0.2 - i only use the scopes
“offline_access”
outlook.office365.com/ IMAP.AccessAsUser.All” and
outlook.office365.com/ SMTP.Send”

Thanks. So trouble is only from cron. Can you also paste a screenshot of setup of your Home- Setup - Email page ?
What happen if you execute the 3 cron tasks at 2 different hours ?
Note that once an email has been processed by 1 job, it can be processed by another one (it is moved or date of last processed email is modified so old email is not processed twice).

Hi,
i am only testing the e-mail collector, for collecting Tickets, i use 3 jobs, Collect_Response_In, Collect_Resonse_Out and Collect_Ticket_Request


They all run with one Cron Job “Ref 1”

I suppose if i create 3 different Cron jobs it should work, because when i deactivate on or two jobs in the e-mail-Collector the last one is allways the one thats being processed.

The other problem is that the mail is not being moved to Archive.

To have the email moved into archive, the use must have write permission on the email box and archive dir.
Is your dir ARCHIVE on the same level than INBOX ?

The User have FullAccess,
image
I changed from Archive to deleted Items


and got a fatal error while collecting

Fatal error: Uncaught Error: Call to undefined function Illuminate\Support\value() in C:\xampp\htdocs\includes\webklex\php-imap\vendor\illuminate\collections\Collection.php:425 Stack trace: #0 C:\xampp\htdocs\includes\webklex\php-imap\src\Message.php(506): Illuminate\Support\Collection->get(‘seen’) #1 C:\xampp\htdocs\includes\webklex\php-imap\src\Message.php(273): Webklex\PHPIMAP\Message->peek() #2 C:\xampp\htdocs\includes\webklex\php-imap\src\Query\Query.php(252): Webklex\PHPIMAP\Message::make(2, 1, Object(Webklex\PHPIMAP\Client), ‘MIME-Version: 1…’, ‘<html xmlns:v="…’, Array, 2, 3) #3 C:\xampp\htdocs\includes\webklex\php-imap\src\Query\Query.php(321): Webklex\PHPIMAP\Query\Query->make(2, 1, ‘MIME-Version: 1…’, ‘<html xmlns:v="…’, Array) #4 C:\xampp\htdocs\includes\webklex\php-imap\src\Query\Query.php(343): Webklex\PHPIMAP\Query\Query->populate(Object(Illuminate\Support\Collection)) #5 C:\xampp\htdocs\emailcollector\class\emailcollector.class.php(1414): Webklex\PHPIMAP\Query\Query->get() #6 C:\xampp\htdocs\admin\emailcollector_card.php(254): EmailCollector->doCollectOneCollector(0) #7 {main} thrown in C:\xampp\htdocs\includes\webklex\php-imap\vendor\illuminate\collections\Collection.php on line 425

Hi,
I upgrade to Version 19.0.0, now everything is working, even the cron jobs, my problems with the cron job was an incorrect “sent items” folder, it had to be in german “gesendete elemente” and my “Archive” was misspelled, correct was “Archiv”.

I have no further Problems wit OAUTH2

Great job done with 19.0.0 !!

1 Like

What PHP version are you using? I am having trouble setting up IMAP access under PHP 8.x

Hi,
i am still on PHP 7.4.33

1 Like