java - Spring集成总是将收到的消息标记为已读

标签 java gmail spring-integration imap

我正在使用 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" 但所有接收消息仍标记为已读。 我使用 Spring Integration 的 4.2.9.RELEASE 版本。 这是我的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

最佳答案

mail.debug java 属性更改为 true

当“should mark messages read”标志设置为 false 时,适配器不应设置 \Seen 标志,这一点可以通过查看调试输出来确认。

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

关于java - Spring集成总是将收到的消息标记为已读,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39839828/

相关文章:

java - 使用 <int-jpa :outbound-channel-adapter 保留实体列表

Spring imap-idle-channel-adapter 基于 Java 的配置

java - Collection.shuffle 不工作 - GWT

java - 对 jtable 进行排序后,如何对列进行编号?

javascript - 尝试使用 Chrome 扩展程序删除 Gmail 中的广告

css - GMail、MailChimp 在表格中的图像之间添加间距

Spring 与 JMS 和 DB 的集成和事务

java - 为什么没有调用 main 方法?每次执行时在java中递归的次数?

java - 如何在 war 中将类与jar文件链接起来? ( java )

c# - 5.7.0 必须先发出 STARTTLS 命令