I have a spring app that sends emails through and reads emails from a GMail inbox and handles any undelivered mail messages that have been sent through the account but then returned as the recipient address is not recognised.
I have this all configured and working but I am also setting a custom header on the outbound message that I would like to retrieve when the returned mail is read. Debugging the app shows that the message is being read correctly but it is missing the custom header value.
Here is my config:
<mail:inbound-channel-adapter id="imapAdapter"
store-uri="#{mailIntegrationProperties['mail.imap.url']}"
java-mail-properties="mailIntegrationProperties"
channel="receiveEmailChannel"
should-delete-messages="false"
should-mark-messages-as-read="true"
auto-startup="true"
max-fetch-size="#{mailIntegrationProperties['mail.max.fetch.size']}">
<int:poller time-unit="SECONDS" fixed-rate="#{mailIntegrationProperties['mail.poller.seconds']}" />
</mail:inbound-channel-adapter>
<int:channel id="receiveEmailChannel" />
<bean id="mailMessageReceiver" class="com.myapp.integration.mail.EmailMessageReceiver" />
<int:service-activator input-channel="receiveEmailChannel" ref="mailMessageReceiver" output-channel="emailEventMessageQueue" method="receive" />
I have left the output-channel of the service-activator off for brevity but the system is working as expected, but just the custom header is missing when I am processing the message.
Any ideas on how to configure Spring to read that custom header?
Cheers!