【发布时间】: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帐户中留下标记为未读的邮件?
【问题讨论】:
标签: java gmail spring-integration imap