-
-
Notifications
You must be signed in to change notification settings - Fork 274
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhancement: Add support for OAUTH2 authentication #421
Comments
OAuth2... how? This is an SMTP library, it connects and authenticates with SMTP servers. I'm not sure where OAth2 comes into the picture here. |
I guess this might be important as it is now required when connecting /authenticating to smtp.office365.com if not changes for a mailbox (which is not always possible, especially if a customer does not want to pass on the actuall password to external solutions in the future). At least the server response states So the question would be how to achieve this type of authentication with simple-java-mail assuming that there is a working OAuth2 token at hand. |
Interesting! Apparently, this was already possible in Sun JavaMail. First of all, to start testing this in order to develop this feature, there are a few steps to get stuff working (took a while to figure this out):
|
… add your own OAuth2 security provider though, Simple Java Mail will use Google's reference implementation from https://github.com/google/gmail-oauth2-tools)
…mentation. Code double check and junit tests still pending...
…mentation. Code double check and junit tests still pending...
I just discovered JavaMail / Jakarta Mail already supported it out of the box, without using Google's version. Guess I'll have to start over :| |
OAUTH2 authentication is now supported with the release of 7.6.0! It's super simple, just use TransportStrategy.OAUTH2 (which is based on TransportStrategy.SMTP_TLS) and use your OAuth2 token as password. MailerBuilder
.withSMTPServer("server host", 587, "username", yourOAuth2Token)
.withTransportStrategy(TransportStrategy.SMTP_OAUTH2)
.buildMailer()
.sendMail(email); Of course, the real challenge now is how are you going to get that OAuth2 token? That varies from platform to platform. |
Hi @bbottema i am trying to use the TransportStrategy.SMTP_OAUTH2 i getting Exception saying |
Hi,
I was wondering what OAuth2 support there is and if there are plans to support it if not.
The text was updated successfully, but these errors were encountered: