Skip to main content
Bill Fox asked 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.

email

Do you know the name of this field for Apex?
1 answer
  1. Jan 25, 2015, 5:59 PM
    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');

0/9000