Spring integration Spring启动集成邮件-授权失败错误

Spring integration Spring启动集成邮件-授权失败错误,spring-integration,jakarta-mail,spring-dsl,Spring Integration,Jakarta Mail,Spring Dsl,下面是我的用于pop3连接的spring配置bean @Bean public IntegrationFlow mailListener() { return IntegrationFlows.from(Mail.pop3InboundAdapter("pop3://sample.test:Sample2test_1@xxx.xx.x.xx/INBOX") .shouldDeleteMessages(true).get(),

下面是我的用于pop3连接的spring配置bean

    @Bean
    public IntegrationFlow mailListener() {
        return IntegrationFlows.from(Mail.pop3InboundAdapter("pop3://sample.test:Sample2test_1@xxx.xx.x.xx/INBOX")
                 .shouldDeleteMessages(true).get(), 
                 e -> e.poller(Pollers.fixedRate(5000).maxMessagesPerPoll(1)))
            .<Message>handle((payload, header) -> logMail(payload))
            .get();
    }
@Bean
公共集成流mailListener(){
返回IntegrationFlows.from(Mail.pop3InboundAdapter)(“pop3://sample.test:Sample2test_1@xxx.xx.x.xx/“收件箱”)
.shouldDeleteMessages(true).get(),
e->e.poller(Pollers.fixedRate(5000.maxMessagesPerPoll(1)))
.handle((有效负载,标题)->日志邮件(有效负载))
.get();
}
还仔细检查了看起来不错的凭证。 获取以下异常

2018-06-22 19:27:54.351错误2092---[ask-scheduler-2] o、 s.integration.handler.LoggingHandler: org.springframework.messaging.MessagingException:发生故障 在投递邮件时;嵌套异常是 javax.mail.AuthenticationFailedException:授权在失败 org.springframework.integration.mail.MailReceivingMessageSource.receive(MailReceivingMessageSource.java:131) 在 org.springframework.integration.endpoint.SourcePollingChannelAdapter.receiveMessage(SourcePollingChannelAdapter.java:224) 在 org.springframework.integration.endpoint.AbstractPollingEndpoint.doPoll(AbstractPollingEndpoint.java:245) 在 org.springframework.integration.endpoint.AbstractPollingEndpoint.access$000(AbstractPollingEndpoint.java:58) 在 org.springframework.integration.endpoint.AbstractPollingEndpoint$1.call(AbstractPollingEndpoint.java:190) 在 org.springframework.integration.endpoint.AbstractPollingEndpoint$1.call(AbstractPollingEndpoint.java:186) 在 org.springframework.integration.endpoint.AbstractPollingEndpoint$Poller$1.run(AbstractPollingEndpoint.java:353) 在 org.springframework.integration.util.ErrorHandlingTaskExecutor$1.run(ErrorHandlingTaskExecutor.java:55) 在 org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:50) 在 org.springframework.integration.util.ErrorHandlingTaskExecutor.execute(ErrorHandlingTaskExecutor.java:51) 在 org.springframework.integration.endpoint.AbstractPollingEndpoint$Poller.run(AbstractPollingEndpoint.java:344) 在 org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54) 在 org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:81) 位于java.util.concurrent.Executors$RunnableAdapter.call(未知 在java.util.concurrent.FutureTask.run(未知源代码)处 java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(未知 来源)在 java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(未知 源代码),位于java.util.concurrent.ThreadPoolExecutor.runWorker(未知 Source)位于java.util.concurrent.ThreadPoolExecutor$Worker.run(未知 源代码)位于java.lang.Thread.run(未知源代码),原因如下: javax.mail.AuthenticationFailedException:授权在失败 com.sun.mail.pop3.POP3Store.protocolConnect(POP3Store.java:208)位于 javax.mail.Service.connect(Service.java:295)位于 javax.mail.Service.connect(Service.java:176)位于 javax.mail.Service.connect(Service.java:125)位于 org.springframework.integration.mail.AbstractMailReceiver.ConnectStoreIfEssential(AbstractMailReceiver.java:286) 在 org.springframework.integration.mail.AbstractMailReceiver.openFolder(AbstractMailReceiver.java:293) 在 org.springframework.integration.mail.AbstractMailReceiver.receive(AbstractMailReceiver.java:319) 在 org.springframework.integration.mail.MailReceivingMessageSource.receive(MailReceivingMessageSource.java:112) ... 还有19个


有这样一个选项:

/**
 * The Java Mail properties.
 * @param javaMailProperties the javaMailProperties.
 * @return the spec.
 * @see AbstractMailReceiver#setJavaMailProperties(Properties)
 */
public S javaMailProperties(Properties javaMailProperties) {
您可以在那里指定
mail.debug=true
,以跟踪交互过程中邮件协议的运行情况

更新

我们在您的日志中记录了以下内容:

DEBUG POP3: connecting to host "172.16.1.45", port 995, isSSL false
19:54:46.746 [task-scheduler-1] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'errorChannel'
19:54:46.753 [task-scheduler-1] DEBUG org.springframework.integration.channel.PublishSubscribeChannel - preSend on channel 'errorChannel', message: ErrorMessage [payload=org.springframework.messaging.MessagingException: failure occurred while polling for mail; nested exception is javax.mail.MessagingException: Connect failed;
  nested exception is:
    java.net.ConnectException: Connection refused: connect, headers={id=290f4c5a-2dfe-d7cb-0637-a0e9f0394daa, timestamp=1529677486753}]

因此,它不能只连接到
172.16.1.45:995
。还没有身份验证握手。

在我的回答中看到更新。我可以将pop.gmail.com替换为172.16.1.45:995吗?我不知道这是怎么回事,是由于代理还是防火墙造成的。好的,你可以这样做。根据您的日志,URL必须类似于
pop3://sharanraj.siluvaipillai:**@pop.gmail.com/INBOX
。但是对于Gmail,你应该考虑你的代码>应用令牌< /代码>,而不是你原来的密码:如果你连不连接,你很可能会碰到A。JavaMail常见问题解答介绍了如何使用。