Reputation: 121
I am supposed to poll 3 email inboxes on our mail server using spring integration I have three inbound email adapters doing that and each poller is handling different business logic. Assuming the inboxes are I1,I2 and I3 The problem arises when , someone sends one email with the three email ids in the To address .([email protected],[email protected],I3.domain.org) . The three pollers pick up the emails from each inbox as expected.
Is there a way to determine the right 'To' address for each email poller and get the value in the mail_to header . Right now it has ([email protected],[email protected],I3.domain.org) in it .
Upvotes: 1
Views: 213
Reputation: 174494
According to the comment to the other answer, by "right" you mean identify which adapter the email originated at.
It's not clear why you would need this, given that each is processed by "different business logic" anyway. I can see that if the adapters feed the same logic it might be useful.
There's currently no way to have the adapter add the header itself.
You could add a <header-enricher/>
right after each adapter to add the header to identify which adapter received the message.
EDIT: (for comments below).
You can't use a <int-mail:header-enricher/>
for custom headers, but you can use a regular header-enricher:
<int:header-enricher ...>
<int:header name="#{T(org.springframework.integration.mail.MailHeaders).TO}"
value="[email protected]" />
<int:header name="x-Foo" value="bar" />
<int:header name="x-Baz" expression="payload.getHeader("x-baz") /> <!-- payload is a MimeMessage -->
</int:header-enricher>
The int-mail
version is just a convenience for the built-in headers.
There's no existing "TO" header to overwrite - it's not populated by the inbound adapter.
Upvotes: 0
Reputation: 29961
It depends on what you mean by "right".
There may be no address in the email header that corresponds to the primary user of the mailbox. Or there may be more than one.
In the simple case, someone has to tell you what the primary email address is that's associated with the mailbox you're polling. Often there's an obvious association, but not always. If someone tells you this, you can examine the incoming messages and try to match them, but again there could be no matches.
How do you want to use this information? That may determine whether it's appropriate to guess, to use heuristics, or to give up because you can't solve the problem.
Upvotes: 1