我正在使用 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 帐户中将邮件标记为未读?
最佳答案
将 mail.debug
java 属性更改为 true
。
当“should mark messages read”标志设置为 false 时,适配器不应设置 \Seen
标志,这一点可以通过查看调试输出来确认。
如果是这种情况,Gmail 可能不会遵守 IMAP 协议(protocol)并使用其他一些标准将邮件标记为已读。
关于java - Spring集成总是将收到的消息标记为已读,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39839828/