Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

spring integation and received date issue

I'm using the latest spring integration (4.1.5) javax.mail (1.4.7) libraries but looks like this issue is sitting there from the beginning.

I'm trying to get received date from mail server via IMAP protocol but SI always returns null. This is because of row 301 in https://github.com/spring-projects/spring-integration/blob/4.1.x/spring-integration-mail/src/main/java/org/springframework/integration/mail/AbstractMailReceiver.java

MimeMessage mimeMessage = new IntegrationMimeMessage((MimeMessage) filteredMessages[i]);

So instead of let me get IMAPMessage instance it makes me to get MimeMessage that has stub for method getReceivedDate:

public Date getReceivedDate() throws MessagingException {
return null;    
}

I see that header contains not null element Received so the only option I see is to parse this header manually.

Is it correct behaviour of SI? Bug or feature? And how to avoid manual parsing of received date header?

like image 822
Dmitrii Borovoi Avatar asked Mar 17 '26 09:03

Dmitrii Borovoi


2 Answers

The received date is available as the internaldate fetch item.

Parsing Received is a great deal of notfun, which is probably why the Spring developers haven't done it yet and why you'll hate doing it. See if internaldate will do.

like image 104
arnt Avatar answered Mar 19 '26 23:03

arnt


I've been looking at the Sun code; it uses the INTERNALDATE fetch item to populate the receivedDate property...

Line 1194 in javamail 1.5.2...

else if (item instanceof INTERNALDATE)
    receivedDate = ((INTERNALDATE)item).getDate();

However, Spring does not expose this; I have created a JIRA issue.

like image 24
Gary Russell Avatar answered Mar 20 '26 00:03

Gary Russell



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!