【问题标题】:Spring integration always mark received messages as readSpring 集成始终将收到的消息标记为已读
【发布时间】:2016-10-03 20:24:27
【问题描述】:

我正在使用 Spring 集成邮件接收传入到我的 gmail 帐户的消息。邮件接收没有问题,但它总是在我的 gmail 帐户中标记为已读。这是我的 XML 配置:

<int:channel id="receiveChannel"/>
replace 'userid and 'password' with the real values
<int-mail:imap-idle-channel-adapter id="customAdapter"
                                    store-uri="imaps://proximahaiz%40gmail.com:myPassword@imap.gmail.com:993/inbox"
                                    channel="receiveChannel"
                                    auto-startup="true"
                                    should-delete-messages="false"
                                    should-mark-messages-as-read="false"
                                    java-mail-properties="javaMailProperties"
/>


<util:properties id="javaMailProperties">
    <prop key="mail.imap.socketFactory.class">javax.net.ssl.SSLSocketFactory</prop>
    <prop key="mail.imap.socketFactory.fallback">false</prop>
    <prop key="mail.store.protocol">imaps</
    <prop key="mail.debug">false</prop>
</

我添加了一个参数 should-mark-messages-as-read = "false" 但所有接收消息仍标记为已读。 我使用 4.2.9.RELEASE 版本的 Spring Integration。 这是我的java代码:

public class GmailInboundImapIdleAdapterServiceImpl implements GmailInboundImapIdleAdapterService {
private static Logger logger = Logger.getLogger(GmailInboundImapIdleAdapterServiceImpl.class);
private static String MAIL_SUBJECT = "mail_subject";
private static String MAIL_FROM = "mail_from";
private static EmailParser emailParser = new EmailParser();
@Autowired
private EmailReceiverService emailReceiverService;


@Override
public void startReceiveEmails() {
    ApplicationContext acProxy = new ClassPathXmlApplicationContext("/integration/gmail-imap-idle-config-proxytest.xml");
    DirectChannel inputChannelProxy = acProxy.getBean("receiveChannel", DirectChannel.class);

    inputChannelProxy.subscribe(new MessageHandler() {
        @Override
        public void handleMessage(Message<?> message) throws MessagingException {
            initMessageReceiving(message);
        }
    });
}

收到邮件到我的应用程序后,我应该怎么做才能在gmail帐户中留下标记为未读的邮件?

logs from debug

【问题讨论】:

    标签: java gmail spring-integration imap


    【解决方案1】:

    将mail.debug java 属性更改为true。

    如果应该标记消息已读标志设置为 false,适配器不应设置 \Seen 标志,这可以通过查看调试输出来确认。

    如果是这种情况,Gmail 可能不遵守 IMAP 协议并使用其他一些标准将邮件标记为已读。

    【讨论】:

    • 它需要使用 FETCH.PEEK,而不是 FETCH 或 EXAMINE,而不是 SELECT。
    • 感谢您的快速回复。上传的日志,你看不到就说,怎么了?
    • 你需要显示更多的日志;仅显示搜索。您不能将整个内容作为文本文件上传吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-10-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-03
    • 2018-01-05
    • 2014-10-26
    相关资源
    最近更新 更多