1

I've installed my jenkins on AWS ec2 Instance and using private subnet and both the port configured in security group of the instance. I'm getting the same error for both cases- port - 465 ssl checked or port 587 ssl unchecked and I'm typing in my password correctly but I still run into this AuthenticaionFailedException.

The settings I used are:

SMTP SERVER: smtp.gmail.com 
Default user e-mail suffix: @gmail.com
USERNAME: username@gmail.com 
PASSWORD: password
USE SSL: checked/unchecked
PORT: 465/587
Reply-to-address: 
Charset: UTF-8

Error I'm getting-

javax.mail.AuthenticationFailedException: 535-5.7.8 Username and 
Password not accepted. Learn more a 535 5.7.8  
https://support.google.com/mail/?p=BadCredentials 
q13sm22788500pfn.150 - gsmtp

at com.sun.mail.smtp.SMTPTransport$Authenticator.authenticate(SMTPTransport.java:809)
at com.sun.mail.smtp.SMTPTransport.authenticate(SMTPTransport.java:752)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:669)
at javax.mail.Service.connect(Service.java:317)
at javax.mail.Service.connect(Service.java:176)
at javax.mail.Service.connect(Service.java:125)
at javax.mail.Transport.send0(Transport.java:194)
at javax.mail.Transport.send(Transport.java:124)
at hudson.tasks.Mailer$DescriptorImpl.doSendTestMail(Mailer.java:672)
at java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:627)
at org.kohsuke.stapler.Function$MethodFunction.invoke(Function.java:396)
at org.kohsuke.stapler.Function$InstanceFunction.invoke(Function.java:408)
at org.kohsuke.stapler.interceptor.RequirePOST$Processor.invoke(RequirePOST.java:77)
at org.kohsuke.stapler.PreInvokeInterceptedFunction.invoke(PreInvokeInterceptedFunction.java:26)
at org.kohsuke.stapler.Function.bindAndInvoke(Function.java:212)
at org.kohsuke.stapler.Function.bindAndInvokeAndServeResponse(Function.java:145)
at org.kohsuke.stapler.MetaClass$11.doDispatch(MetaClass.java:535)
at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:58)
at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:747)
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:878)
at org.kohsuke.stapler.MetaClass$4.doDispatch(MetaClass.java:280)
at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:58)
at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:747)
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:878)
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:676)
at org.kohsuke.stapler.Stapler.service(Stapler.java:238)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:873)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1623)
at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:154)
at jenkins.telemetry.impl.UserLanguages$AcceptLanguageFilter.doFilter(UserLanguages.java:128)
at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:151)
at hudson.util.PluginServletFilter.doFilter(PluginServletFilter.java:157)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1610)
at hudson.security.csrf.CrumbFilter.doFilter(CrumbFilter.java:64)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1610)
at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:84)
at hudson.security.UnwrapSecurityExceptionFilter.doFilter(UnwrapSecurityExceptionFilter.java:51)
at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
at jenkins.security.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:117)
at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
at org.acegisecurity.providers.anonymous.AnonymousProcessingFilter.doFilter(AnonymousProcessingFilter.java:125)
at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
at org.acegisecurity.ui.rememberme.RememberMeProcessingFilter.doFilter(RememberMeProcessingFilter.java:142)
at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
at org.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:271)
at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
at jenkins.security.BasicHeaderProcessor.doFilter(BasicHeaderProcessor.java:93)
at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
at org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:249)
at hudson.security.HttpSessionContextIntegrationFilter2.doFilter(HttpSessionContextIntegrationFilter2.java:67)
at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
at hudson.security.ChainedServletFilter.doFilter(ChainedServletFilter.java:90)
at hudson.security.HudsonFilter.doFilter(HudsonFilter.java:171)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1610)
at org.kohsuke.stapler.compression.CompressionFilter.doFilter(CompressionFilter.java:49)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1610)
at hudson.util.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:82)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1610)
at org.kohsuke.stapler.DiagnosticThreadNameFilter.doFilter(DiagnosticThreadNameFilter.java:30)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1610)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:540)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:146)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:524)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:257)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1701)
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:255)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1345)
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:203)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:480)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1668)
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:201)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1247)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:144)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
at org.eclipse.jetty.server.Server.handle(Server.java:502)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:370)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:267)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:305)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103)
at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:117)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:333)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:310)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:168)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:126)
at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:366)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:765)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:683)
at java.lang.Thread.run(Thread.java:748)

Note: I'm new to jenkins, aws so please try to put each and every steps so that I can able to understand and resolve this issue. Thanks in advance.

Kavya
  • 101
  • 1
  • 2
  • 8
  • Have you checked [this](https://stackoverflow.com/questions/35347269/javax-mail-authenticationfailedexception-535-5-7-8-username-and-password-not-ac) link? – Technext Oct 02 '19 at 11:54
  • Yes, I've gone through with this link but I didn't find solution. – Kavya Oct 02 '19 at 16:29
  • Please check the answer [here](https://stackoverflow.com/a/57621730/361089) and see if it works – Technext Oct 02 '19 at 16:35
  • Thanks for your response, but still I'm facing same issue. – Kavya Oct 03 '19 at 04:44
  • javax.mail.AuthenticationFailedException: 534-5.7.14 Please 534-5.7.14 log in via your web browser and then try again. 534-5.7.14 Learn more at 534 5.7.14 https://support.google.com/mail/answer/78754 v5sm1327002pfv.76 - gsmtp . I'm following all the instructions but still not able to resolve the issue. – Kavya Oct 03 '19 at 04:57
  • Did you follow the steps described [here](https://support.google.com/mail/answer/7126229?visit_id=637056792678923088-2147656284&rd=2#cantsignin) to generate `app` (in your case, Jenkins) password? If you have already done that, then you need to downgrade the [Mailer](https://wiki.jenkins.io/display/JENKINS/Mailer) plugin version to `1.23` – Technext Oct 03 '19 at 06:04
  • Thank you, now its working fine... but I want to know if we use some organization mail id then I think we can't allow less secure app setting with that organization mail. It would be risky then how we will do. – Kavya Oct 03 '19 at 06:26
  • The Google link that i referred to was to suggest you use `App Password` and not the less secure option. Did you try using the `App Password` thing? Also, did you change the Mailer plugin version to get this working? What version of Mailer plugin do you have right now? – Technext Oct 03 '19 at 07:56
  • I've 1.23 version of mailer plugin right now – Kavya Oct 03 '19 at 08:26
  • Were you using some other version earlier? Also, did you try using the `App Password` mentioned above? – Technext Oct 03 '19 at 08:31
  • I've tried and it was working fine but not with my organization domain. For e.g if I'll use user.name@abc.com then it will show same error because I'm not able to do two step verification. Please help if you have any solution for this. I'm using domain mail id in gmail. – Kavya Oct 03 '19 at 09:58
  • If your SMTP server is `smtp.gmail.com`, then it expects a GMail credentail. You will have to check with your company and get their SMTP server details to get things working. – Technext Oct 03 '19 at 10:31
  • Can't we find smtp server details – Kavya Oct 03 '19 at 11:49
  • Outlook (in case you use it) Account settings might be one place to look for. I suggest you just contact your system admin, explain what you're trying to achieve and get the details. – Technext Oct 03 '19 at 14:07
  • Thanks for your response. Now, it's working fine. – Kavya Oct 03 '19 at 17:59
  • What did you do? – Technext Oct 03 '19 at 19:16

1 Answers1

3

These settings worked fine for me

Implement Three things with given SMTP settings

  1. Disable two factor authentication: https://myaccount.google.com/security
  2. Allow less secure apps : https://www.google.com/settings/security/lesssecureapps
  3. Allow new devices using the link: https://g.co/allowaccess

SMTP Settings:

  • smtp.gmail.com
  • Port: 465
  • Use SSL
  • From Email Address
  • Gmail Username
  • Gmail Password
  • Recipient Email Address
karthik v
  • 1,104
  • 1
  • 14
  • 22