huytmb / mail-receiver

Mail Receiver - Using Spring Boot with Spring Integration
27 stars 17 forks source link

Caused by: jakarta.mail.AuthenticationFailedException: failed to connect, no password specified? what should i do? i added password in application.yml #2

Open AKDEVLPR opened 1 year ago

AKDEVLPR commented 1 year ago

. _ _ /\ / '_ () \ \ \ \ ( ( )\ | ' | '| | ' \/ ` | \ \ \ \ \/ _)| |)| | | | | || (| | ) ) ) ) ' |__| .|| ||| |\, | / / / / =========|_|==============|__/=//// :: Spring Boot :: (v3.0.1)

2022-12-29T11:41:43.239+05:30 INFO 14716 --- [ main] c.h.m.MailReceiveApplication : Starting MailReceiveApplication using Java 17.0.1 with PID 14716 (D:\java\EmailOperation\MailReceive\target\classes started by arunkumar.r in D:\java\EmailOperation\MailReceive) 2022-12-29T11:41:43.243+05:30 INFO 14716 --- [ main] c.h.m.MailReceiveApplication : The following 1 profile is active: "dev" 2022-12-29T11:41:43.556+05:30 DEBUG 14716 --- [ main] faultConfiguringBeanFactoryPostProcessor : SpEL function '#xpath' isn't registered: there is no spring-integration-xml.jar on the classpath. 2022-12-29T11:41:43.561+05:30 INFO 14716 --- [ main] faultConfiguringBeanFactoryPostProcessor : No bean named 'errorChannel' has been explicitly defined. Therefore, a default PublishSubscribeChannel will be created. 2022-12-29T11:41:43.583+05:30 DEBUG 14716 --- [ main] faultConfiguringBeanFactoryPostProcessor : The '#jsonPath' SpEL function cannot be registered: there is no jayway json-path.jar on the classpath. 2022-12-29T11:41:43.585+05:30 INFO 14716 --- [ main] faultConfiguringBeanFactoryPostProcessor : No bean named 'integrationHeaderChannelRegistry' has been explicitly defined. Therefore, a default DefaultHeaderChannelRegistry will be created. 2022-12-29T11:41:43.832+05:30 INFO 14716 --- [ main] c.h.m.config.MailReceiverConfiguration : IMAP connection url: imaps://arunofficial302@gmail.com:officialPassword3021@imap.gmail.com:993/inbox 2022-12-29T11:41:43.930+05:30 DEBUG 14716 --- [ main] faultConfiguringBeanFactoryPostProcessor : Spring Integration global properties:

spring.integration.channels.autoCreate=true spring.integration.channels.error.requireSubscribers=true spring.integration.taskScheduler.poolSize=10 spring.integration.readOnly.headers= spring.integration.channels.maxUnicastSubscribers=2147483647 spring.integration.endpoints.noAutoStartup= spring.integration.channels.error.ignoreFailures=true spring.integration.messagingTemplate.throwExceptionOnLateReply=false spring.integration.channels.maxBroadcastSubscribers=2147483647

2022-12-29T11:41:43.948+05:30 DEBUG 14716 --- [ main] .s.i.c.GlobalChannelInterceptorProcessor : No global channel interceptors. 2022-12-29T11:41:43.950+05:30 INFO 14716 --- [ main] o.s.i.endpoint.EventDrivenConsumer : Adding {logging-channel-adapter:_org.springframework.integration.errorLogger} as a subscriber to the 'errorChannel' channel 2022-12-29T11:41:43.950+05:30 INFO 14716 --- [ main] o.s.i.channel.PublishSubscribeChannel : Channel 'application.errorChannel' has 1 subscriber(s). 2022-12-29T11:41:43.950+05:30 INFO 14716 --- [ main] o.s.i.endpoint.EventDrivenConsumer : started bean '_org.springframework.integration.errorLogger' 2022-12-29T11:41:43.950+05:30 INFO 14716 --- [ main] o.s.i.endpoint.EventDrivenConsumer : Adding {service-activator:mailReceiverConfiguration.receive.serviceActivator} as a subscriber to the 'receiveEmailChannel' channel 2022-12-29T11:41:43.950+05:30 INFO 14716 --- [ main] o.s.integration.channel.DirectChannel : Channel 'application.receiveEmailChannel' has 1 subscriber(s). 2022-12-29T11:41:43.951+05:30 INFO 14716 --- [ main] o.s.i.endpoint.EventDrivenConsumer : started bean 'mailReceiverConfiguration.receive.serviceActivator' 2022-12-29T11:41:43.952+05:30 INFO 14716 --- [ main] o.s.i.e.SourcePollingChannelAdapter : started bean 'mailMessageSource.inboundChannelAdapter' 2022-12-29T11:41:43.959+05:30 INFO 14716 --- [ main] c.h.m.MailReceiveApplication : Started MailReceiveApplication in 0.965 seconds (process running for 1.593) 2022-12-29T11:41:43.982+05:30 DEBUG 14716 --- [autohost-task-1] o.s.integration.mail.ImapMailReceiver : connecting to store [imaps://arunofficial302@gmail.com] 2022-12-29T11:41:44.127+05:30 DEBUG 14716 --- [autohost-task-1] o.s.i.channel.PublishSubscribeChannel : preSend on channel 'bean 'errorChannel'', message: ErrorMessage [payload=org.springframework.messaging.MessagingException: failure occurred while polling for mail, headers={id=2c1feb2c-7036-c666-9f73-96922fa3d007, timestamp=1672294304125}] 2022-12-29T11:41:44.127+05:30 DEBUG 14716 --- [autohost-task-1] o.s.integration.handler.LoggingHandler : bean '_org.springframework.integration.errorLogger.handler' for component '_org.springframework.integration.errorLogger' received message: ErrorMessage [payload=org.springframework.messaging.MessagingException: failure occurred while polling for mail, headers={id=2c1feb2c-7036-c666-9f73-96922fa3d007, timestamp=1672294304125}] 2022-12-29T11:41:44.128+05:30 ERROR 14716 --- [autohost-task-1] o.s.integration.handler.LoggingHandler : org.springframework.messaging.MessagingException: failure occurred while polling for mail at org.springframework.integration.mail.MailReceivingMessageSource.doReceive(MailReceivingMessageSource.java:74) at org.springframework.integration.endpoint.AbstractMessageSource.receive(AbstractMessageSource.java:142) at org.springframework.integration.endpoint.SourcePollingChannelAdapter.receiveMessage(SourcePollingChannelAdapter.java:212) at org.springframework.integration.endpoint.AbstractPollingEndpoint.doPoll(AbstractPollingEndpoint.java:443) at org.springframework.integration.endpoint.AbstractPollingEndpoint.pollForMessage(AbstractPollingEndpoint.java:412) at org.springframework.integration.endpoint.AbstractPollingEndpoint.lambda$createPoller$4(AbstractPollingEndpoint.java:348) at org.springframework.integration.util.ErrorHandlingTaskExecutor.lambda$execute$0(ErrorHandlingTaskExecutor.java:57) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) at java.base/java.lang.Thread.run(Thread.java:833) Caused by: jakarta.mail.AuthenticationFailedException: failed to connect, no password specified? at jakarta.mail.Service.connect(Service.java:376) at jakarta.mail.Service.connect(Service.java:222) at jakarta.mail.Service.connect(Service.java:171) at org.springframework.integration.mail.AbstractMailReceiver.connectStoreIfNecessary(AbstractMailReceiver.java:334) at org.springframework.integration.mail.AbstractMailReceiver.openFolder(AbstractMailReceiver.java:341) at org.springframework.integration.mail.AbstractMailReceiver.receive(AbstractMailReceiver.java:373) at org.springframework.integration.mail.MailReceivingMessageSource.doReceive(MailReceivingMessageSource.java:62) ... 9 more

2022-12-29T11:41:44.130+05:30 DEBUG 14716 --- [autohost-task-1] o.s.i.channel.PublishSubscribeChannel : postSend (sent=true) on channel 'bean 'errorChannel'', message: ErrorMessage [payload=org.springframework.messaging.MessagingException: failure occurred while polling for mail, headers={id=2c1feb2c-7036-c666-9f73-96922fa3d007, timestamp=1672294304125}] 2022-12-29T11:41:48.958+05:30 DEBUG 14716 --- [autohost-task-2] o.s.integration.mail.ImapMailReceiver : connecting to store [imaps://arunofficial302@gmail.com] 2022-12-29T11:41:48.959+05:30 DEBUG 14716 --- [autohost-task-2] o.s.i.channel.PublishSubscribeChannel : preSend on channel 'bean 'errorChannel'', message: ErrorMessage [payload=org.springframework.messaging.MessagingException: failure occurred while polling for mail, headers={id=56304bae-3e86-b429-e23e-ca59386be17b, timestamp=1672294308959}] 2022-12-29T11:41:48.960+05:30 DEBUG 14716 --- [autohost-task-2] o.s.integration.handler.LoggingHandler : bean '_org.springframework.integration.errorLogger.handler' for component '_org.springframework.integration.errorLogger' received message: ErrorMessage [payload=org.springframework.messaging.MessagingException: failure occurred while polling for mail, headers={id=56304bae-3e86-b429-e23e-ca59386be17b, timestamp=1672294308959}] 2022-12-29T11:41:48.960+05:30 ERROR 14716 --- [autohost-task-2] o.s.integration.handler.LoggingHandler : org.springframework.messaging.MessagingException: failure occurred while polling for mail at org.springframework.integration.mail.MailReceivingMessageSource.doReceive(MailReceivingMessageSource.java:74) at org.springframework.integration.endpoint.AbstractMessageSource.receive(AbstractMessageSource.java:142) at org.springframework.integration.endpoint.SourcePollingChannelAdapter.receiveMessage(SourcePollingChannelAdapter.java:212) at org.springframework.integration.endpoint.AbstractPollingEndpoint.doPoll(AbstractPollingEndpoint.java:443) at org.springframework.integration.endpoint.AbstractPollingEndpoint.pollForMessage(AbstractPollingEndpoint.java:412) at org.springframework.integration.endpoint.AbstractPollingEndpoint.lambda$createPoller$4(AbstractPollingEndpoint.java:348) at org.springframework.integration.util.ErrorHandlingTaskExecutor.lambda$execute$0(ErrorHandlingTaskExecutor.java:57) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) at java.base/java.lang.Thread.run(Thread.java:833) Caused by: jakarta.mail.AuthenticationFailedException: failed to connect, no password specified? at jakarta.mail.Service.connect(Service.java:376) at jakarta.mail.Service.connect(Service.java:222) at jakarta.mail.Service.connect(Service.java:171) at org.springframework.integration.mail.AbstractMailReceiver.connectStoreIfNecessary(AbstractMailReceiver.java:334) at org.springframework.integration.mail.AbstractMailReceiver.openFolder(AbstractMailReceiver.java:341) at org.springframework.integration.mail.AbstractMailReceiver.receive(AbstractMailReceiver.java:373) at org.springframework.integration.mail.MailReceivingMessageSource.doReceive(MailReceivingMessageSource.java:62) ... 9 more

2022-12-29T11:41:48.960+05:30 DEBUG 14716 --- [autohost-task-2] o.s.i.channel.PublishSubscribeChannel : postSend (sent=true) on channel 'bean 'errorChannel'', message: ErrorMessage [payload=org.springframework.messaging.MessagingException: failure occurred while polling for mail, headers={id=56304bae-3e86-b429-e23e-ca59386be17b, timestamp=1672294308959}] 2022-12-29T11:41:53.967+05:30 DEBUG 14716 --- [autohost-task-1] o.s.integration.mail.ImapMailReceiver : connecting to store [imaps://arunofficial302@gmail.com] 2022-12-29T11:41:53.967+05:30 DEBUG 14716 --- [autohost-task-1] o.s.i.channel.PublishSubscribeChannel : preSend on channel 'bean 'errorChannel'', message: ErrorMessage [payload=org.springframework.messaging.MessagingException: failure occurred while polling for mail, headers={id=19ccf776-e38e-ca32-b9c9-9690d2064465, timestamp=1672294313967}] 2022-12-29T11:41:53.967+05:30 DEBUG 14716 --- [autohost-task-1] o.s.integration.handler.LoggingHandler : bean '_org.springframework.integration.errorLogger.handler' for component '_org.springframework.integration.errorLogger' received message: ErrorMessage [payload=org.springframework.messaging.MessagingException: failure occurred while polling for mail, headers={id=19ccf776-e38e-ca32-b9c9-9690d2064465, timestamp=1672294313967}] 2022-12-29T11:41:53.969+05:30 ERROR 14716 --- [autohost-task-1] o.s.integration.handler.LoggingHandler : org.springframework.messaging.MessagingException: failure occurred while polling for mail at org.springframework.integration.mail.MailReceivingMessageSource.doReceive(MailReceivingMessageSource.java:74) at org.springframework.integration.endpoint.AbstractMessageSource.receive(AbstractMessageSource.java:142) at org.springframework.integration.endpoint.SourcePollingChannelAdapter.receiveMessage(SourcePollingChannelAdapter.java:212) at org.springframework.integration.endpoint.AbstractPollingEndpoint.doPoll(AbstractPollingEndpoint.java:443) at org.springframework.integration.endpoint.AbstractPollingEndpoint.pollForMessage(AbstractPollingEndpoint.java:412) at org.springframework.integration.endpoint.AbstractPollingEndpoint.lambda$createPoller$4(AbstractPollingEndpoint.java:348) at org.springframework.integration.util.ErrorHandlingTaskExecutor.lambda$execute$0(ErrorHandlingTaskExecutor.java:57) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) at java.base/java.lang.Thread.run(Thread.java:833) Caused by: jakarta.mail.AuthenticationFailedException: failed to connect, no password specified? at jakarta.mail.Service.connect(Service.java:376) at jakarta.mail.Service.connect(Service.java:222) at jakarta.mail.Service.connect(Service.java:171) at org.springframework.integration.mail.AbstractMailReceiver.connectStoreIfNecessary(AbstractMailReceiver.java:334) at org.springframework.integration.mail.AbstractMailReceiver.openFolder(AbstractMailReceiver.java:341) at org.springframework.integration.mail.AbstractMailReceiver.receive(AbstractMailReceiver.java:373) at org.springframework.integration.mail.MailReceivingMessageSource.doReceive(MailReceivingMessageSource.java:62) ... 9 more

2022-12-29T11:41:53.969+05:30 DEBUG 14716 --- [autohost-task-1] o.s.i.channel.PublishSubscribeChannel : postSend (sent=true) on channel 'bean 'errorChannel'', message: ErrorMessage [payload=org.springframework.messaging.MessagingException: failure occurred while polling for mail, headers={id=19ccf776-e38e-ca32-b9c9-9690d2064465, timestamp=1672294313967}]

JerLord04 commented 1 year ago

Can you fixed this issue?

Diplo2by commented 1 month ago

Hi @AKDEVLPR

I noticed that your email credentials are exposed in this issue. For security reasons, please remove the sensitive information immediately. Here are some steps you should follow:

  1. Edit the issue to remove the credentials.
  2. Change the email password to ensure it is no longer valid.
  3. Use environment variables to manage sensitive data securely in the future.
xniti3x commented 2 weeks ago
in class MailReceiverConfiguration ...

@Bean
    public MailReceiver imapMailReceiver( @Value("${mail.imap.username}") String username, @Value("${mail.imap.password}") String password, @Value("${mail.imap.host}") String host, @Value("${mail.imap.port}") String port ) throws UnsupportedEncodingException {

        username = URLEncoder.encode(username, "UTF-8");
        password = URLEncoder.encode(password, "UTF-8");
        String url =  "imaps://"+username+":"+password+"@"+host+":"+port+"/inbox";

        log.info("IMAP connection url: {}", url);

        ImapMailReceiver imapMailReceiver = new ImapMailReceiver(url);"
...