Thursday, April 25, 2013

Salesforce "Email Privileges Revoked" error message

When you write apex code in Salesforce to send email in Sandbox instance, you may find error "Email Privileges Revoked" error message.

You may never see this error earlier. What is the caused?

As per Spring'13, Salesforce have added a way for you to control the type of email your organization sends, with the new Access level setting in Setup > Administration SetupEmail Administration > Deliverability. 

While you typically won’t change this setting day-to-day, these options can be useful when you need to temporarily suspend outbound email or when you’re working with sandboxes, for example:

  • No access: Prevents all outbound email to and from users.
  • System email only: Allows only automatically generated emails, such as new user and password reset emails.
  • All email: Allows all types of outbound email. Default for new, non-sandbox organizations.
Tip: The System email only setting is especially useful for controlling email sent from sandboxes so that testing and development work doesn’t send test emails to your users.
  • Newly created sandboxes default to System email only.
  • Sandboxes created before ’Spring 13 default to All email.

You may not be able to edit the Access level if has restricted your organization’s ability to change this setting.

Summary: by change access level to "All email", it should solve the issue in Sandbox.