function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Bill FoxBill Fox 

email "delivered-to" field in apex

In reference to:
Messaging.InboundEmailResult handleInboundEmail(Messaging.inboundEmail email,                                                   Messaging.InboundEnvelope env)

All received emails in the "env.toAddress" field show the forwarding address entered on the GoDaddy email
mail@o-2fggmz1j2........knonz.f-.........na1.apex.salesforce.com which I would expect.

So, I do not know who the email is for.

However, in debug file there is field a called "Delivered-To" which does have the original send to email address before forwarding.
I tried both "email.delivered-to" and "env.delivered-to" but they are not recognized variables.
Log file showing delivered-to field
Do you know the name of this field for Apex?
pconpcon
That looks like it may be a header value.  You can access this by doing
 
Map<String, String> headerMap = new Map<String, String>();

for (Messaging.InboundEmailHeader header: email.headers) {
    headerMap.put(header.name, header.value);
}

String deliveredTo = headerMap.get('Delivered-To');