[GH-ISSUE #493] Feature Request: Add XOAUTH2 Authentication #317

Closed
opened 2026-03-15 13:51:07 +03:00 by kerem · 10 comments
Owner

Originally created by @lukaszbob on GitHub (May 9, 2025).
Original GitHub issue: https://github.com/axllent/mailpit/issues/493

Thank you for your work.

Is it possible to add annother authentication mode?
For example O365 uses XOAUTH2 auth, disabling plaing authentication by default.

SMTP XOUATH2 example: https://github.com/nekomeowww/exchange-smtp-client
MS reference: https://learn.microsoft.com/en-us/exchange/client-developer/legacy-protocols/how-to-authenticate-an-imap-pop-smtp-application-by-using-oauth

Originally created by @lukaszbob on GitHub (May 9, 2025). Original GitHub issue: https://github.com/axllent/mailpit/issues/493 Thank you for your work. Is it possible to add annother authentication mode? For example O365 uses XOAUTH2 auth, disabling plaing authentication by default. SMTP XOUATH2 example: https://github.com/nekomeowww/exchange-smtp-client MS reference: https://learn.microsoft.com/en-us/exchange/client-developer/legacy-protocols/how-to-authenticate-an-imap-pop-smtp-application-by-using-oauth
kerem 2026-03-15 13:51:07 +03:00
  • closed this issue
  • added the
    stale
    label
Author
Owner

@axllent commented on GitHub (May 9, 2025):

Hi @lukaszbob. It is not clear to me where you are requesting XOAUTH2 to be added to, but I assume you mean the relay functionality (to relay messages from Mailpit via O365's SMTP servers)? If so, then please see #171.

<!-- gh-comment-id:2867897918 --> @axllent commented on GitHub (May 9, 2025): Hi @lukaszbob. It is not clear to me where you are requesting XOAUTH2 to be added to, but I assume you mean the relay functionality (to relay messages from Mailpit via O365's SMTP servers)? If so, then please see #171.
Author
Owner

@lukaszbob commented on GitHub (May 10, 2025):

Yes, it's in the relay module.

I fully understand that OAuth authentication is beyond the scope of this app, but I'd like to use an already obtained token for authentication.

In the case of Office 365, the token can only be used with XOAUTH2 mode. So this feature request includes:

  1. Adding a new authentication mode option alongside the existing ones (PLAIN, LOGIN, and CRAM-MD5).

  2. Passing the provided token using the XOAUTH2 header, as shown in the linked example..

<!-- gh-comment-id:2868573499 --> @lukaszbob commented on GitHub (May 10, 2025): Yes, it's in the relay module. I fully understand that OAuth authentication is beyond the scope of this app, but I'd like to use an already obtained token for authentication. In the case of Office 365, the token can only be used with XOAUTH2 mode. So this feature request includes: 1. Adding a new authentication mode option alongside the existing ones (PLAIN, LOGIN, and CRAM-MD5). 2. Passing the provided token using the XOAUTH2 header, as shown in the linked example..
Author
Owner

@axllent commented on GitHub (May 10, 2025):

Please excuse my ignorance here (and general lack of technical understanding of the core OAUTH2 protocol), but I thought that OAUTH2 tokens were automatically rotated and needed to be regularly refreshed?

<!-- gh-comment-id:2868723040 --> @axllent commented on GitHub (May 10, 2025): Please excuse my ignorance here (and general lack of technical understanding of the core OAUTH2 protocol), but I thought that OAUTH2 tokens were automatically rotated and needed to be regularly refreshed?
Author
Owner

@lukaszbob commented on GitHub (May 12, 2025):

In general, yes — but in the case of O365, I believe it works more like an application password. I have a token with a one-year expiration period.

<!-- gh-comment-id:2871150093 --> @lukaszbob commented on GitHub (May 12, 2025): In general, yes — but in the case of O365, I believe it works more like an application password. I have a token with a one-year expiration period.
Author
Owner

@axllent commented on GitHub (May 13, 2025):

Is this token something you generate through the o365 admin interface, or did you generate it (or extract it from) via another tool? I still get the feeling that implementing this is a bit of a hack, and that Mailpit users will expect token generation to be part of this too.

<!-- gh-comment-id:2875709124 --> @axllent commented on GitHub (May 13, 2025): Is this token something you generate through the o365 admin interface, or did you generate it (or extract it from) via another tool? I still get the feeling that implementing this is a bit of a hack, and that Mailpit users will expect token generation to be part of this too.
Author
Owner

@lukaszbob commented on GitHub (May 13, 2025):

It was generated in Microsoft Entra panel as Application, and then Client Secret.

https://learn.microsoft.com/en-us/entra/identity-platform/howto-create-service-principal-portal

Image

<!-- gh-comment-id:2876093962 --> @lukaszbob commented on GitHub (May 13, 2025): It was generated in Microsoft Entra panel as Application, and then Client Secret. https://learn.microsoft.com/en-us/entra/identity-platform/howto-create-service-principal-portal ![Image](https://github.com/user-attachments/assets/b9acf934-4f8c-4dec-bd25-324876758545)
Author
Owner

@axllent commented on GitHub (May 17, 2025):

I am currently working on this, but I have no way to test if my implementation is valid/works. It is my understanding that an XOATH2 login uses only a token and no username/password.

I don't suppose there is any way you could create a temporary token for me to test with (valid for just a couple of days), and provide me with with any other detail I should know (smtp server, limitations in "From" etc)? (axllent AT gmail DOT com)

<!-- gh-comment-id:2887913438 --> @axllent commented on GitHub (May 17, 2025): I am currently working on this, but I have no way to test if my implementation is valid/works. It is my understanding that an XOATH2 login uses **only** a token and no username/password. I don't suppose there is any way you could create a temporary token for me to test with (valid for just a couple of days), and provide me with with any other detail I should know (smtp server, limitations in "From" etc)? (axllent AT gmail DOT com)
Author
Owner

@lukaszbob commented on GitHub (May 19, 2025):

Yes, it's only the token, but I need to double-check the mechanism for obtaining it — I’m afraid I might have been misled earlier.
I’ll try testing the XOAUTH2 header on my own later this week.

<!-- gh-comment-id:2890249137 --> @lukaszbob commented on GitHub (May 19, 2025): Yes, it's only the token, but I need to double-check the mechanism for obtaining it — I’m afraid I might have been misled earlier. I’ll try testing the XOAUTH2 header on my own later this week.
Author
Owner

@github-actions[bot] commented on GitHub (May 27, 2025):

This issue has been marked as stale because it has been open for 7 days with no activity.

<!-- gh-comment-id:2910906086 --> @github-actions[bot] commented on GitHub (May 27, 2025): This issue has been marked as stale because it has been open for 7 days with no activity.
Author
Owner

@github-actions[bot] commented on GitHub (May 31, 2025):

This issue was closed because there has been no activity since being marked as stale.

<!-- gh-comment-id:2923990023 --> @github-actions[bot] commented on GitHub (May 31, 2025): This issue was closed because there has been no activity since being marked as stale.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/mailpit#317
No description provided.