Collect Emails with OAuth2 and Microsoft 365 does not work

Hi,

I tried in a test environment to link Doli 18.02 with OAuth2 to Microsoft Office 365 Exchange Mailbox for sending and receiving.
Sending eMails works pretty fine but the email collector brings a ‘failed to refresh access token’ as show in the screenshot. In case deactivate the scope ‘offline_access’ in Dolibarr OAuth Settings I get an error message : “Failed to refresh access token”
I look to several posts in this forum as well as tried different things out but always with the same result.

May some one has a fresh Idea what I can check or what I have to modify to also collect emails and not only send emails ?

Thanks in advance,
Christian

Bild2

User Mailbox Settings:

Bild3

App access :

Bild4

Hi Christian,
i am having similar problems, sending no problems, but collecting is not working, i found a problem in your settings, use 993 instead of 143 for the IMAP Port.

in summer this year i was able to collect the mails, my only problem was moving into archive, with version 18.0.2 i can´t collect any more, not sure what the reason is, i can refresh an get the amount of mails, but when i try to test collection or try to collect i get an http 500 error.

lg
Jason.

Hello! Can you tell me, were you able to fix this problem? I have the exact same one… When I press the “Refresh” button, I see the number of emails in the mail folder, but when I try to collect these emails, I get a “Gateway Timeout”

Hi Ed,
yes i did solve it, after i upgraded to version 19.0.0, i was surprised, even moving the mails to the folder “Archiv” and the planed jobs is working, after i corrected the collecting folder to the German translation, eg not “Sent Items” i needed “Gesendete Elemente”.

I initially have version 19 installed :sweat_smile: Could you please share what settings you have in OAuth and what permissions are granted to the application in AAD? Also, please tell me, is it necessary to enter a password in the Email collector settings? When I press the “Refresh” button and it shows the actual number of emails - it works even when I do not enter a password for the account. I am confused… :smiling_face_with_tear: I’ve never had problems connecting Office 365 mail to any system before. Thank you in advance! :pray:

Sure,
in Dolibarr you need the right scopes, in the E-Mail-Collector you do need the right password as well,

in Azure,

hope it is of any help.

PS
I am still with PHP 7.4.33

1 Like

I have been trying to get this to work as well. The error with “no wrapper found” is solved if you use PHP 7.4.33 (or similar version), it does not work on 8.x !
I have tested this on 5 different installations and only the one with the lower PHP version is able to receive emails… The issue is that the docker image I want to use has PHP 8.3 bundled into it, so I am finding a way to make my own image… I however hope the authors see this and will fix this for us :wink:
Anyway, are you able to successfully get the email collector to create 3rd parties etc? Can you share your configs? @eldy is there a chance to look into why the IMAP email works on 7.x but not on 8.x?

1 Like

Hi Leifure,
i did not create a collector to create 3rd parties now, i will give it a try this weekend, i am curious :slight_smile:

I have trouble to find the variables we can use for the filtering… “tmp_from” “tmp_subject” etc, have you found any documentation for this or samples?

There is no list. You can choose the name you want for temp variables. Examples are using $tmp_xxx so we understand it is temp variable, but you can use any value to store a value and reuse it to save it into another parameter.

Thank you for your information @eldy, this makes sense, even though I do not know the main variables and how I can map them to my temporary ones?
Anyway, I have now successfully been able to connect Dolibarr 19 to Microsoft’s email servers and sending via SMTP works. Email collector on the other hand is able to log into the mail server and match the emails and return 0 collected emails when I set the match email to a nonsense email like “sdgfgsdfgsdfg@dfgsdfgsdfg.com”, but if the conditions are met then the email collector crashes! I have tried with having just a filter for unread messages and the operations to create a lead, but this crashes Dolibarr every time, no matter which parameters I put in there… I need to restart the docker container to get Dolibarr up again… Full crash…
Do you have any idea what it could be?