0

以下是我用于 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.endpoint.AbstractPollingEndpoint.doPoll(AbstractPollingEndpoint.java:245) 在 org.springframework.integration.endpoint.AbstractPollingEndpoint.access$000(AbstractPollingEndpoint.java:58) 在 org.springframework.integration.endpoint.AbstractPollingEndpoint$1。

4

1 回答 1

0

有一个这样的选项:

/**
 * 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. 还没有身份验证握手。

于 2018-06-22T14:18:28.923 回答