![](/img/trans.png)
[英]Asynchronous mail receiving with Spring Boot and Spring integration
[英]Spring boot integration mail - authorization failed error
以下是我的用於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();
}
還要仔細檢查看起來不錯的憑據。 得到以下異常,
2018-06-22 19:27:54.351錯誤2092-[ask-scheduler-2] osintegration.handler.LoggingHandler:org.springframework.messaging.MessagingException:輪詢郵件時發生故障; 嵌套異常是javax.mail.AuthenticationFailedException:授權在org.springframework.integration.endpoint.SourcePollingChannelAdapter.receiveMessage(SourcePollingChannelAdapter.java:224)的org.springframework.integration.mail.MailReceivingMessageSource.receive(MailReceivingMessageSource.java:131)處失敗org.springframework.integration.endpoint.AbstractPollingEndpoint.doPoll(AbstractPollingEndpoint.java:245)at org.springframework.integration.endpoint.AbstractPollingEndpoint.access $ 000(AbstractPollingEndpoint.java:58)at org.springframework.integration.endpoint.AbstractPollingEndpoint $ 1。在org.springframework.integration.endpoint.AbstractPollingEndpoint $ 1.call(AbstractPollingEndpoint.java:190)在org.springframework.integration.endpoint.AbstractPollingEndpoint $ Poller $ 1.run(AbstractPollingEndpoint.java:353)處調用(AbstractPollingEndpoint.java:186)在org.springframew上的org.springframework.integration.util.ErrorHandlingTaskExecutor $ 1.run(ErrorHandlingTaskExecutor.java:55) org.springframework.integration.util.ErrorHandlingTaskExecutor.execute(ErrorHandlingTaskExecutor.java:51)上的ork.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:50)org.springframework.integration.endpoint.AbstractPollingEndpoint $ Poller.run( org.springframework.scheduling.concurrent的org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)的AbstractPollingEndpoint.java:344)java.util。 .Executors $ RunnableAdapter.call(未知源),java.util.concurrent.FutureTask.run(未知源),java.util.concurrent.ScheduledThreadPoolExecutor $ ScheduledFutureTask.access $ 201(未知源),java.util.concurrent.ScheduledThreadPoolExecutor $ java.util.concurrent.ThreadPoolExecutor.run的ScheduledFutureTask.run(未知源)java.lang.Thread.run(未知源)的java.util.concurrent.ThreadPoolExecutor $ Worker.run(未知源) )由以下原因引起:javax.mail.AuthenticationFailedException:com.sun.mail.pop3.POP3Store.protocolConnect(POP3Store.java:208)的授權在javax.mail.Service.connect(Service.java:295)處失敗org.springframework.java.mail.Service.connect(Service.java:125)的org.springframework.integration.mail.AbstractMailReceiver.connectStoreIfNecessary(AbstractMailReceiver.java:286)的.Service.connect(Service.java:176)。 org.springframework.integration.mail.MailReceivingMessageSource.receive(MailReceivingMessageSource.java:org.springframework.integration.mail.AbstractMailReceiver.receive(AbstractMailReceiver.java:319)處的integration.mail.AbstractMailReceiver.openFolder(AbstractMailReceiver.java:293) 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
。 尚無身份驗證握手。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.