I will be having email alerts sent to clients and I want their replies to go to an Email Service address. But I can't simply make that long address the "From" address because that must be an org-wide approved email address, which you cannot do with an email service address.

So, it's been suggested to me to use an org-wide approved address ([email protected] etc) and simply set up that email account to automatically forward all of its mail to the long email service address. However, I can't use the long email service address as a destination address in the forwarding process either. Gmail needs to send a verification to whatever email will be used and I cannot perform an approval for the email address, or at least I don't know how to.

How can I accomplish this ?

Thank you.

1 Answer 1


What I have done in the past for an email service address is capture the email requesting verification and forward it to a real address so the link can be clicked to verify. Then you can use the long address as a forwarding

You can modify the below code as appropriate

global class email_Handler implements Messaging.InboundEmailHandler {

        global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email, Messaging.InboundEnvelope envelope) {

            Messaging.InboundEmailResult result = new Messaging.InboundEmailresult();
            String attachment_body;

            //Reroute Verification Email
            if(email.plainTextBody.contains('We have received the following request to add this')){
                sendVerificationEmail(email, 'xxxxx');
                return result;

        private void sendVerificationEmail(Messaging.InboundEmail email, String toAddress){

            Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
            String[] toAddresses = new String[] {toAddress};


            Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });


  • 1
    i love it! almost like a judo move on SFDC itself
    – cropredy
    Oct 2, 2015 at 19:35
  • ha ! Nice one @Eric. Thanks a bunch !
    – Zoom_v
    Oct 2, 2015 at 19:43
  • @Eric - I keep getting an error : expecting a semi-colon, found '(' on line 14 which is the line starting with "private void sendVerification...". I've looked at it and I don't see the problem. I must be overlooking something obvious. Any suggestions....?
    – Zoom_v
    Oct 2, 2015 at 20:00
  • 1
    @Zoom_v - Yea, forgot a bracket. Updated
    – Eric
    Oct 2, 2015 at 20:02
  • Eric, I tried your code but I am still not getting the verification email. I even tried removing the if(email.plainTextBody.contains('We have received the following request to add this')){ condition so that in any case I will get the email but had no luck either. However if I manually send an email to the long email service address I am receiving the email. Any clue what I could be missing here? Feb 15, 2017 at 13:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .