Loading
Enhance Salesforce with Code
Table of Contents
Select Filters

          No results
          No results
          Here are some search tips

          Check the spelling of your keywords.
          Use more general search terms.
          Select fewer filters to broaden your search.

          Search all of Salesforce Help
          Define Email Services

          Define Email Services

          Set up an email service to handle incoming email, and configure the service to process messages according to your users' needs.

          Required Editions

          Available in: Salesforce Classic (not available in all orgs) and Lightning Experience

          Available in: Enterprise, Performance, Unlimited, and Developer Editions

          Use of email services in installed AppExchange packages also available in: Essentials, Group, and Professional Editions

          User Permissions Needed
          To configure Apex email services and email service addresses: Customize Application
          To create Apex classes: Author Apex
          1. From Setup, enter Email Services in the Quick Find box, then select Email Services.
          2. Click New Email Service, or click Edit to change an existing email service.
          3. Specify the name of the email service.
          4. Choose the Apex class you want this email service to use to process messages.
            The Apex class you choose must implement the Messaging.InboundEmailHandler interface. For example:
            global class myHandler implements Messaging.InboundEmailHandler {
                        global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email, Messaging.InboundEnvelope envelope) {
                            Messaging.InboundEmailResult result = new Messaging.InboundEmailresult();
                            return result;
                        }
                    }
            For information on the InboundEmail object, see Using the InboundEmail Object.
          5. Choose the types of attachments you want the email service to accept. The options are:
            None The email service accepts the message but discards any attachment.
            Text Attachments Only

            The email service only accepts the following types of attachments:

            • Attachments with a Multipurpose Internet Mail Extension (MIME) type of text.
            • Attachments with a MIME type of application/octet-stream and a file name that ends with either a .vcf or .vcs extension. These attachments are saved as text/x-vcard and text/calendar MIME types, respectively.

            Messages with attachments other than these types are accepted, but the attachments are discarded.

            Binary Attachments Only

            The email service only accepts binary attachments, such as image, audio, application, and video files. Binary attachments have a limit of 5 MB per attachment.

            Messages with attachments that aren’t binary are accepted, but the attachments are discarded.

            All The email service accepts any type of attachment.

            An email service can only process attachments if you configure the email service to accept attachments and use an Apex class that processes the types of attachments the email service accepts.

            Email services can’t accept inline attachments, such as graphics inserted in email messages.

          6. Optionally, select the Advanced Email Security Settings checkbox to configure the email service to verify the legitimacy of the sending server before processing a message. The email service uses the following authentication protocols to verify the sender's legitimacy:If Advanced Security permission is disabled in your org, Advanced Email Settings aren't available.
            • DKIM
            • DMARC
            • SPF

            If the sending server passes at least one of these protocols and doesn’t fail any, the email service accepts the email. If the server fails a protocol or doesn’t support any of the protocols, the email service performs the action specified in the Unauthenticated Sender Action failure response setting. Two exceptions apply.

            • If DMARC passes and SPF fails, the email service accepts the email.
            • If DKIM fails and any other protocol passes, the email service accepts the email.

            If Advanced Security permission is disabled in your org, Advanced Email Settings aren't available. Before selecting the Authenticate Senders checkbox, ensure that the senders that you expect to use the email service support at least one of the authentication protocols listed. For information on these authentication protocols, see the following websites:

          7. Email services reject email messages and notify the sender if the email exceeds approximately 25 MB (combined body text, body HTML, and attachments). This size varies depending on language and character set.
          8. You can convert text attachments to binary attachments.
          9. Optionally, configure this email service only to accept messages from certain senders by listing their email addresses and domains in the Accept Email From text box. Separate multiple entries with commas. For example: george@mycompany.com, yahoo.com, gmail.com. If the Accept Email From text box has a value and the email service receives a message from an unlisted email address or domain, the email service performs the action specified in the Unauthorized Sender Action failure response setting.

            Leave this field blank if you want the email service to receive email from any email address.

            Note
            Note You can also authorize email addresses and domains at the email service address-level. See Defining Email Service Addresses.

            If both the email service and email service address are configured to accept messages only from certain senders, the email service processes messages only from senders that are listed in the Accept Email From text boxes on both the email service and the email service address.

          10. Select the Active checkbox if you want the email service to be activated when you click Save.
          11. Configure the failure response settings, which determine how the email service responds if an attempt to access this email service fails for the following reasons:The failure response options are:
            Over Email Rate Limit Action Determines what the email service does with messages if the total number of messages processed by all email services combined has reached the daily limit for your organization. Salesforce calculates the limit by multiplying the number of user licenses by 1,000; maximum 1,000,000. For example, if you have 10 licenses, your org can process up to 10,000 email messages a day.
            Deactivated Email Address Action Determines what the email service does with messages received at an email address that is inactive.
            Deactivated Email Service Action Determines what the email service does with messages it receives when the email service itself is inactive.
            Unauthenticated Sender Action Determines what the email service does with messages that fail or don’t support any of the authentication protocols if the Authenticate Senders checkbox is selected.
            Unauthorized Sender Action Determines what the email service does with messages received from senders who aren’t listed in the Accept From Email text box on either the email service or email service address.

            The failure response options are:

            Bounce Message The email service returns the message to the sender or to the Automated Case User for On-Demand Email-to-Case, with a notification that explains why the message was rejected.
            Discard Message The email service deletes the message without notifying the sender.
            Requeue Message (Over Email Rate Limit Action Only) The email service queues the message for processing in the next 24 hours. If the message isn’t processed within 24 hours, the email service returns the message to the sender with a notification that explains why the message was rejected.
          12. To send error email messages to a specified address instead of the sender's email address, select Enable Error Routing and specify the destination email address in Route Error Emails to This Email Address. This action prevents the sender being notified when email services can’t process an incoming email.
            Note
            Note The Enable Error Routing feature only applies to the following five failure scenarios, and only when "Bounce Message" is selected as the response action:
            • Over Email Rate Limit Action
            • Deactivated Email Address Action
            • Deactivated Email Service Action
            • Unauthenticated Sender Action
            • Unauthorized Sender Action
            If "Discard Message" or "Requeue Message" is selected for any of these failure responses, error routing does not occur.
          13. Click Save to save your changes, or Save and New Email Address to create email addresses for this email service, as described in Defining Email Service Addresses.
           
          Loading
          Salesforce Help | Article