Skip to content
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

GMail sending with 2FA and app password doesn't work #118

Open
dodalovic opened this issue Oct 18, 2019 · 8 comments
Open

GMail sending with 2FA and app password doesn't work #118

dodalovic opened this issue Oct 18, 2019 · 8 comments
Assignees

Comments

@dodalovic
Copy link

I have enabled 2FA and I generated app password for my account.
When I supply configuration in mail-sender.zip sample app , I'm getting an error:

➜ java -jar target/mail-sender-1.0.0-SNAPSHOT-fat.jar
HTTP server started on port 8888
Oct 18, 2019 1:24:57 PM io.vertx.core.impl.launcher.commands.VertxIsolatedDeployer
INFO: Succeeded in deploying verticle
mail sending failed! io.vertx.core.impl.NoStackTraceThrowable: AUTH XOAUTH2 failed 535-5.7.8 Username and Password not accepted. Learn more at
535 5.7.8  https://support.google.com/mail/?p=BadCredentials b19sm2650728wmb.42 - gsmtp
@pmlopes
Copy link
Member

pmlopes commented Oct 18, 2019

GMail will require you to use XOAUTH to authenticate. Please look at this PR: #94

You need to create a google app for it and get a token, either from the command line or using the oauth2 client after you setup the app.

I'll keep this issue open as a reminder that this information needs to be added to the manual.

@pmlopes pmlopes self-assigned this Oct 18, 2019
@dodalovic
Copy link
Author

Am I understanding well that if I use token generated via app passwords screen

image

and using that as password in config doesn't work anymore?

@dodalovic
Copy link
Author

dodalovic commented Oct 18, 2019

@pmlopes what's interesting was that when using the solution described here I was able to send mail using password generated in the Google Application passwords screen

The solution is using plain om.sun.mail:javax.mail:1.6.2 dependency

@pmlopes
Copy link
Member

pmlopes commented Oct 18, 2019

Ok, so you can try a different thing. If the application password works, perhaps you should block XOAUTH from the SASL list. In that case XOAUTH won't be used and the username/password approach will be used instead.

Look for the auth algorithms options on the mail client options. By default if none is set the following list is used:

    "XOAUTH2",
    "DIGEST-MD5",
    "CRAM-SHA256",
    "CRAM-SHA1",
    "CRAM-MD5",
    "PLAIN",
    "LOGIN"

So if you would remove the first one, by saying:

    DIGEST-MD5,
    CRAM-SHA256,
    CRAM-SHA1,
    CRAM-MD5,
    PLAIN,
    LOGIN

And you can even remove more if you know the SASL used by javax.mail

@KlausSchaefersAtWork
Copy link

So, what was the solution for this issue?

@KlausSchaefersAtWork
Copy link

KlausSchaefersAtWork commented Dec 12, 2021

This solved the issue for me:

	mailConfig.setAuthMethods("DIGEST-MD5, CRAM-SHA256, CRAM-SHA1, CRAM-MD5, PLAIN, LOGIN");

@gaol
Copy link
Member

gaol commented Dec 13, 2021

Hi @KlausSchaefersAtWork, with #124 fixed in 4.0.0+, if XOAUTH2 failed, it turns to next auth method supported by this client, would you please try ?

@KlausSchaefersAtWork
Copy link

Hi, I cannot easily move to 4.0, I am stuck with 3.9. But thanks for letting me know. I will try to upgrade to Vertx 4.x in the next weeks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

5 participants
@gaol @pmlopes @dodalovic @KlausSchaefersAtWork and others