2 options:
Option 1
1) Create a class which implements the inboundHandler.
global class VerifyOrgWideEmailAddress implements Messaging.InboundEmailHandler {
global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email,
Messaging.InboundEnvelope envelope) {
Messaging.InboundEmailResult result = new Messaging.InboundEmailresult();
//This is one time thing that you will have to perfrom everytime you setup the org wide email address.
//Use this html body to fetch the verification link and open it in a browser to verify it.
System.debug('The email Body ==> '+ email.plainTextBody);
result.success = true;
return result;
}
}
2) Create a email service and link the above class that you just created.
3) Create a new email address under the Email Services.
4) Copy the email address that you just created and use it to create the Org Wide Email address.
5) Open the developer console and wait for a log with the Operation , 'EmailToApexHandler'. Open the log and search for the verification Link keyword.
6) Copy-paste the verification link in browser and that should be it.
7) Now, you would need to update the email services class to handle your custom logic.
Option 2.
1) Say you have setup an org email address which is pointing to [email protected]
.
2) Create an email service.
3) You will have to setup an email forwarding in the email server (for this example the email forwarding will be setup in gmail) to forward all the email to the email services email that you have created.