Reputation: 1315
Setup
I am currently using gmail for polling emails sent to a catch-all address, where the string before the @ has to be processed by the system.
I use IMAP for the integration.
My backend is in .Net (not that relevant)
My challenge
WHen writing to multiple email addresses in the same mail, e.g. [email protected], [email protected] and [email protected], things work when all catch all addresses are explicitly specified in the "To"-field. In this case the "To" header contains all addresses. However, when sending to the 3 catch all addresses using a distribution list or using BCC, it is not possible to see all the catch-all addresses that the mail was sent to.
How would people go around solving this problem? I dont need to use gmail - Exchange would be just as fine. I would prefer not to build my own mail server from scratch / downloading some C# mail server.
Any input on this is very appreciated!
EDIT: As suggested, this is to be done earlier in the chain and it will be solved by programming some custom logic as suggested.
Upvotes: 1
Views: 705
Reputation: 9685
These problems are typically not solved using IMAP, but rather one step earlier in the chain, in the LDA.
The local delivery agent, LDA among friends, is the piece of software that's responsible for taking the localpart and mapping it to a mailbox (or forwarding, etc). LDAs sometimes store the localpart in the stored message, but far from always. As Max says, if it's stored you can find it in Received or Delivered-To.
Some LDAs, I don't know whether it's 10% or 50%, can be programmed in a language called Sieve. That language is sometimes used to solve problems like the one I assume you have. You might check whether that's supported by whatever software you use.
Here's a simple example of Sieve:
if envelope "from" :is :domain "mailtjenester.no" {
redirect "[email protected]";
}
(That's a spammer-for-hire, and whatever they send me, I forward to someone at the spamco. He can do the unsubscribing for me.)
Upvotes: 2