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

Mail sending (Gmail) doesn't work #4510

Closed
dodalovic opened this issue Oct 10, 2019 · 20 comments
Closed

Mail sending (Gmail) doesn't work #4510

dodalovic opened this issue Oct 10, 2019 · 20 comments
Labels
good first issue Good for newcomers kind/bug Something isn't working
Milestone

Comments

@dodalovic
Copy link
Contributor

I was following official guide
app.zip

@dodalovic dodalovic added the kind/bug Something isn't working label Oct 10, 2019
@dodalovic
Copy link
Contributor Author

curl --request POST \
  --url http://localhost:8181/mails \
  --header 'accept: text/plain' \
  --header 'content-type: application/json' \
  --data '{
	"recipient": "[email protected]",
	"text": "mail body"
}'

@dodalovic
Copy link
Contributor Author

I’m wondering if someone came across the same issue as I did 😞 ?

@jaikiran
Copy link
Member

I haven't checked the app, but do you see any errors or exceptions when you invoke that endpoint? Any logs?

@dodalovic
Copy link
Contributor Author

@jaikiran Absolutely nothing :)

@dodalovic
Copy link
Contributor Author

Saw that MockMailboxImpl is being executed while sending, not sure if mock should be executed in runtime 😕

@dodalovic
Copy link
Contributor Author

@jaikiran
image

@dodalovic
Copy link
Contributor Author

When I set quarkus.mailer.mock=false in my application.properties, I get the following (I'm sure I'm using proper credentials) :

2019-10-12 17:16:48,000 ERROR [io.und.req.io] (executor-thread-1) Exception handling request d3b5505f-227e-421f-ab69-d90374c12ab7-1 to /visits/email/patient/1: org.jboss.resteasy.spi.UnhandledException: java.util.concurrent.CompletionException: 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 m18sm20578699wrg.97 - gsmtp
        at org.jboss.resteasy.core.ExceptionHandler.handleApplicationException(ExceptionHandler.java:106)
        at org.jboss.resteasy.core.ExceptionHandler.handleException(ExceptionHandler.java:372)
        at org.jboss.resteasy.core.SynchronousDispatcher.writeException(SynchronousDispatcher.java:209)
        at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:496)
        at org.jboss.resteasy.core.SynchronousDispatcher.lambda$invoke$4(SynchronousDispatcher.java:252)
        at org.jboss.resteasy.core.SynchronousDispatcher.lambda$preprocess$0(SynchronousDispatcher.java:153)
        at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:363)
        at org.jboss.resteasy.core.SynchronousDispatcher.preprocess(SynchronousDispatcher.java:156)
        at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:238)
        at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:249)
        at io.quarkus.resteasy.runtime.ResteasyFilter$ResteasyResponseWrapper.sendError(ResteasyFilter.java:64)
        at io.undertow.servlet.handlers.DefaultServlet.doGet(DefaultServlet.java:172)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:686)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:791)
        at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74)
        at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129)
        at io.quarkus.resteasy.runtime.ResteasyFilter.doFilter(ResteasyFilter.java:28)
        at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
        at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
        at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84)
        at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:63)
        at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68)
        at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
        at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:133)
        at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
        at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
        at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:65)
        at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
        at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
        at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
        at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:270)
        at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:59)
        at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:116)
        at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:113)
        at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)
        at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
        at io.quarkus.undertow.runtime.UndertowDeploymentRecorder$8$1$1.call(UndertowDeploymentRecorder.java:433)
        at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:250)
        at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:59)
        at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:82)
        at io.undertow.server.Connectors.executeRootHandler(Connectors.java:290)
        at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:669)
        at io.quarkus.runtime.CleanableExecutor$CleaningRunnable.run(CleanableExecutor.java:224)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
        at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2011)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1535)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1395)
        at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
        at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29)
        at java.lang.Thread.run(Thread.java:748)
        at org.jboss.threads.JBossThread.run(JBossThread.java:479)
Caused by: java.util.concurrent.CompletionException: 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 m18sm20578699wrg.97 - gsmtp
        at java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:292)
        at java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:308)
        at java.util.concurrent.CompletableFuture.uniAccept(CompletableFuture.java:647)
        at java.util.concurrent.CompletableFuture$UniAccept.tryFire(CompletableFuture.java:632)
        at java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:474)
        at java.util.concurrent.CompletableFuture.completeExceptionally(CompletableFuture.java:1977)
        at io.vertx.axle.AsyncResultCompletionStage.lambda$toCompletionStage$0(AsyncResultCompletionStage.java:20)
        at io.vertx.ext.mail.impl.MailClientImpl.lambda$returnResult$5(MailClientImpl.java:155)
        at io.vertx.core.impl.ContextImpl.executeTask(ContextImpl.java:369)
        at io.vertx.core.impl.EventLoopContext.lambda$executeAsync$0(EventLoopContext.java:38)
        at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163)
        at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:416)
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:515)
        at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:918)
        at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        at java.lang.Thread.run(Thread.java:748)
Caused by: 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 m18sm20578699wrg.97 - gsmtp

@cescoffier
Copy link
Member

The issue is gmail does not accept username and password anymore:
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 m18sm20578699wrg.97

@dodalovic
Copy link
Contributor Author

dodalovic commented Oct 14, 2019

@cescoffier Seems they are, considering this sample project: mail-sending-example.zip

@dodalovic
Copy link
Contributor Author

dodalovic commented Oct 16, 2019

Bug still present in 0.25.0. I suspect vertx-mail-client might be a culprit.

@dodalovic
Copy link
Contributor Author

@jaikiran @cescoffier Is there someone available for support? Or to point me out if I can provide any? As stated above, I suspect vertx-mail-client has some issues

@jaikiran
Copy link
Member

@dodalovic Sorry, I haven't been able to find some time to look into this. I will see if I can find some time later this week, if no one else get to it before that.

@kenfinnigan
Copy link
Member

I encountered something similar last week in setting up some home networking.

It was simply not possible for me to send an email to the GMail SMTP server with a simple email/password combination of the account.

You need to create an application passcode that can be used with the email address. See https://support.google.com/accounts/answer/185833?hl=en

@dodalovic
Copy link
Contributor Author

@kenfinnigan Yep, did that, doesn’t help 😞
@jaikiran thanks!

@t-shaguy
Copy link

Same here!

@Sanne
Copy link
Member

Sanne commented Nov 7, 2019

ok that gmail requires an "app password". But why is there no error, and why was it necessary to set quarkus.mailer.mock=false ? Doesn't seem right; is someone looking to get to the bottom of that?

@jaikiran
Copy link
Member

jaikiran commented Nov 8, 2019

@Sanne I haven't had time to get to this and given that this involves having to use a gmail id, I probably won't be able to get to this any soon.

@Sanne Sanne added the good first issue Good for newcomers label Nov 8, 2019
@Sanne
Copy link
Member

Sanne commented Nov 8, 2019

thanks @jaikiran , and sure didn't mean to rush anyone :) Just checking that we agree there's something to be done here, anyone could look to improve this.

Adding the "good first issue" as I think it might not be too hard. I hope I'm not wrong :)

@akochnev
Copy link
Contributor

I ran into this same issue with quarkus 1.0.0.CR1
FWIW, the solution specified in vert-x3/vertx-mail-client#118 does work and allow the injected mailer approach to be used in quarkus, e.g. :

.. (in application.properties) ...

note - XOAUTH2 is removed from the list

quarkus.mailer.auth-methods=DIGEST-MD5 CRAM-SHA256 CRAM-SHA1 CRAM-MD5 PLAIN LOGIN
....

... in quarkus app ...
@ApplicationScoped
public class QuarkusMailSender implements MailSender {

@ConfigProperty(name = "mailer.recipient") 
String recipient;
@Inject
Mailer mailer;

@Override
public void send(SolReq req) {
    mailer.send(Mail.withText(recipient,String.format("sol req from %s",req.email),req.message));
}

}
...
I still have to dig a bit deeper to sort out on how to make it work with an oauth token (which should be possible), but at least this restores the quarkus setup into a working state.

akochnev added a commit to akochnev/quarkus that referenced this issue Nov 13, 2019
…kusio#4510

By default, the vertx mail client and google both default to XOAUTH2 and that method needs to be disabled in order for password authentication (with app passwords to work)

Addresses issue quarkusio#4510
gsmet pushed a commit to akochnev/quarkus that referenced this issue Nov 14, 2019
…kusio#4510

By default, the vertx mail client and google both default to XOAUTH2 and that method needs to be disabled in order for password authentication (with app passwords to work)

Addresses issue quarkusio#4510
machi1990 added a commit that referenced this issue Nov 14, 2019
Updated mailer docs with option for google password auth , issue #4510
jmartisk pushed a commit to jmartisk/quarkus that referenced this issue Nov 15, 2019
…kusio#4510

By default, the vertx mail client and google both default to XOAUTH2 and that method needs to be disabled in order for password authentication (with app passwords to work)

Addresses issue quarkusio#4510
gsmet pushed a commit that referenced this issue Nov 15, 2019
By default, the vertx mail client and google both default to XOAUTH2 and that method needs to be disabled in order for password authentication (with app passwords to work)

Addresses issue #4510
@gsmet
Copy link
Member

gsmet commented Nov 18, 2019

The documentation has been updated.

@gsmet gsmet closed this as completed Nov 18, 2019
@gsmet gsmet added this to the 1.0.0.Final milestone Nov 18, 2019
ia3andy pushed a commit to dmlloyd/quarkus that referenced this issue Nov 19, 2019
…kusio#4510

By default, the vertx mail client and google both default to XOAUTH2 and that method needs to be disabled in order for password authentication (with app passwords to work)

Addresses issue quarkusio#4510
Simulant87 pushed a commit to Simulant87/quarkus that referenced this issue Nov 23, 2019
…kusio#4510

By default, the vertx mail client and google both default to XOAUTH2 and that method needs to be disabled in order for password authentication (with app passwords to work)

Addresses issue quarkusio#4510
Simulant87 pushed a commit to Simulant87/quarkus that referenced this issue Nov 23, 2019
…kusio#4510

By default, the vertx mail client and google both default to XOAUTH2 and that method needs to be disabled in order for password authentication (with app passwords to work)

Addresses issue quarkusio#4510
mmusgrov pushed a commit to mmusgrov/quarkus that referenced this issue Dec 13, 2019
…kusio#4510

By default, the vertx mail client and google both default to XOAUTH2 and that method needs to be disabled in order for password authentication (with app passwords to work)

Addresses issue quarkusio#4510
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

8 participants