# \[IGN-6887\] Read E-Mails on IMAP with OAUTH2

**URL:** <https://forum.inductiveautomation.com/t/ign-6887-read-e-mails-on-imap-with-oauth2/67184>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [December 2, 2022, 3:54pm UTC](https://forum.inductiveautomation.com/t/ign-6887-read-e-mails-on-imap-with-oauth2/67184 "2022-12-02T15:54:46Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [December 2, 2022, 3:54pm UTC](https://forum.inductiveautomation.com/t/ign-6887-read-e-mails-on-imap-with-oauth2/67184/1 "2022-12-02T15:54:46Z")

</div>

I have a customer that is using e-mail to transfer data to Ignition. The script that is being used to retrieve and process those e-mails and attachments is using the python imaplib. Now with MSFT and Google dropping basic authentication, that library doesn't want to connect which is not surprising.

We are working with the customer to move away from this mechanism, but in the event that the other system can't do anything other than e-mail, what options do we have to fill this gap? I started messing with the javax.mail library, but it isn't included with Ignition at this moment and it seems that to include this would require wrapping it in a module which would involve learning that and time that we don't have at the moment.

Is there another library included with Ignition that we can use to read e-mails off an IMAP server using OAUTH2? Or is it pretty much just the javamail implementation that we need to work with?

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [December 2, 2022, 3:55pm UTC](https://forum.inductiveautomation.com/t/ign-6887-read-e-mails-on-imap-with-oauth2/67184/2 "2022-12-02T15:55:29Z")

</div>

You would need to work with the javamail implementation, just like our new Oauth2 email profiles do.

---

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [December 2, 2022, 3:57pm UTC](https://forum.inductiveautomation.com/t/ign-6887-read-e-mails-on-imap-with-oauth2/67184/3 "2022-12-02T15:57:03Z")

</div>

OK.

For reference, can we just drop the .jar file in on the gateway and just use it in gateway scoped scripts? For client side we'd have to roll it up into a wrapper correct?

Or with the new Oauth2 implementation, will javamail be included?

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [December 2, 2022, 4:09pm UTC](https://forum.inductiveautomation.com/t/ign-6887-read-e-mails-on-imap-with-oauth2/67184/4 "2022-12-02T16:09:33Z")

</div>

javamail has always been included in gateway scope.

If you're able to upgrade to the latest Ignition then you can probably use the new generic OAuth client management that was introduced to support the new email profile.

The hardest part about all of this is the Oauth token management, not using javamail. That barely changes.

---

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [December 2, 2022, 4:12pm UTC](https://forum.inductiveautomation.com/t/ign-6887-read-e-mails-on-imap-with-oauth2/67184/5 "2022-12-02T16:12:02Z")

</div>

OK I wasn't aware that it was included in the gateway scope. That's why I seem lost. 😃

Their gateway is sitting at 8.1.22. Does that include the OAuth token stuff or will it be a later version?

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [December 2, 2022, 4:12pm UTC](https://forum.inductiveautomation.com/t/ign-6887-read-e-mails-on-imap-with-oauth2/67184/6 "2022-12-02T16:12:28Z")

</div>

Mmm, I think it's in the 8.1.24 nightly right now. So I guess it's not released yet.

---

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [December 2, 2022, 4:13pm UTC](https://forum.inductiveautomation.com/t/ign-6887-read-e-mails-on-imap-with-oauth2/67184/7 "2022-12-02T16:13:37Z")

</div>

OK that's fine. I'll let them know and then we can evaluate when that version is released.

I do hope that they figure out a different method... reading an email inbox is clunky.

Thanks!

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [December 2, 2022, 4:18pm UTC](https://forum.inductiveautomation.com/t/ign-6887-read-e-mails-on-imap-with-oauth2/67184/8 "2022-12-02T16:18:00Z")

</div>

> [@bschroeder](#):
>
> reading an email inbox is clunky.

Sure is. They probably saw somebody doing this via FTP and said "HOLD MY BEER".

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [December 2, 2022, 4:18pm UTC](https://forum.inductiveautomation.com/t/ign-6887-read-e-mails-on-imap-with-oauth2/67184/9 "2022-12-02T16:18:44Z")

</div>

> [@Kevin.Herron](#):
>
> via FTP and said "HOLD MY BEER".

Ok, really did laugh out loud for that.

---

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [December 2, 2022, 4:23pm UTC](https://forum.inductiveautomation.com/t/ign-6887-read-e-mails-on-imap-with-oauth2/67184/10 "2022-12-02T16:23:21Z")

</div>

Yeah.... that's pretty much what they said. The other system is an older ERP system that doesn't play well with anything.

---

<div class="post-metadata">

**Author:** ![Kyle\_Chase](https://avatars.discourse-cdn.com/v4/letter/k/9de0a6/32.png) [@Kyle\_Chase](https://forum.inductiveautomation.com/u/Kyle_Chase)\
**Post date:** [December 2, 2022, 5:20pm UTC](https://forum.inductiveautomation.com/t/ign-6887-read-e-mails-on-imap-with-oauth2/67184/11 "2022-12-02T17:20:58Z")

</div>

Just a thought, but, you could maybe look at a SMTP to Protocol gateway, such as [Mailrise](https://github.com/YoRyan/mailrise) or [smtp2http](https://github.com/alash3al/smtp2http)?

---

<div class="post-metadata">

**Author:** ![jspecht](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jspecht/32/6465_2.png) [@jspecht](https://forum.inductiveautomation.com/u/jspecht)\
**Post date:** [December 3, 2022, 1:31am UTC](https://forum.inductiveautomation.com/t/ign-6887-read-e-mails-on-imap-with-oauth2/67184/12 "2022-12-03T01:31:11Z")

</div>

> [@Kevin.Herron](#):
>
> If you're able to upgrade to the latest Ignition then you can probably use the new generic OAuth client management that was introduced to support the new email profile.

Unfortunately Ignition's new OAuth2 APIs are not yet exposed in the public SDK, but since @bschroeder is interested in using it, I'll see if I can prioritize exposing it publicly...
