diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php
index f9c7d69cf5f04200c1044fba91b295f837bc2a05..0f4173f87636679e175edd5c1064fd808b970b53 100644
--- a/apps/files_sharing/lib/Controller/ShareAPIController.php
+++ b/apps/files_sharing/lib/Controller/ShareAPIController.php
@@ -23,6 +23,7 @@
  */
 namespace OCA\Files_Sharing\Controller;
 
+use OC\Share20\Exception\ProviderException;
 use OCP\AppFramework\Http\DataResponse;
 use OCP\AppFramework\OCS\OCSBadRequestException;
 use OCP\AppFramework\OCS\OCSException;
@@ -556,7 +557,11 @@ class ShareAPIController extends OCSController {
 		$userShares = $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_USER, $path, $reshares, -1, 0);
 		$groupShares = $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_GROUP, $path, $reshares, -1, 0);
 		$linkShares = $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_LINK, $path, $reshares, -1, 0);
-		$mailShares = $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_EMAIL, $path, $reshares, -1, 0);
+		if ($this->shareManager->shareProviderExists(\OCP\Share::SHARE_TYPE_EMAIL)) {
+			$mailShares = $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_EMAIL, $path, $reshares, -1, 0);
+		} else {
+			$mailShares = [];
+		}
 		$shares = array_merge($userShares, $groupShares, $linkShares, $mailShares);
 
 		if ($this->shareManager->outgoingServer2ServerSharesAllowed()) {
diff --git a/apps/files_sharing/lib/Controller/ShareesAPIController.php b/apps/files_sharing/lib/Controller/ShareesAPIController.php
index d5d877f4673d97a48d84beceb4aefcc84d7e2a6d..4af332a118491c6c057ef50e1c47e500b2c03d98 100644
--- a/apps/files_sharing/lib/Controller/ShareesAPIController.php
+++ b/apps/files_sharing/lib/Controller/ShareesAPIController.php
@@ -446,6 +446,11 @@ class ShareesAPIController extends OCSController {
 			$shareTypes = array_diff($shareTypes, [Share::SHARE_TYPE_REMOTE]);
 		}
 
+		if (!$this->shareManager->shareProviderExists(Share::SHARE_TYPE_EMAIL)) {
+			// Remove mail shares from type array, because the share provider is not loaded
+			$shareTypes = array_diff($shareTypes, [Share::SHARE_TYPE_EMAIL]);
+		}
+
 		$this->shareWithGroupOnly = $this->config->getAppValue('core', 'shareapi_only_share_with_group_members', 'no') === 'yes';
 		$this->shareeEnumeration = $this->config->getAppValue('core', 'shareapi_allow_share_dialog_user_enumeration', 'yes') === 'yes';
 		$this->limit = (int) $perPage;
diff --git a/core/js/sharedialogview.js b/core/js/sharedialogview.js
index 30cb0b1fbfd5b5c328cf8a91e4753d8c780e45a6..c22d9469da8d0df36266ca977599bcfb80d237dc 100644
--- a/core/js/sharedialogview.js
+++ b/core/js/sharedialogview.js
@@ -154,7 +154,11 @@
 						var users   = result.ocs.data.exact.users.concat(result.ocs.data.users);
 						var groups  = result.ocs.data.exact.groups.concat(result.ocs.data.groups);
 						var remotes = result.ocs.data.exact.remotes.concat(result.ocs.data.remotes);
-						var emails = result.ocs.data.exact.emails.concat(result.ocs.data.emails);
+						if (typeof(result.ocs.data.emails) !== 'undefined') {
+							var emails = result.ocs.data.exact.emails.concat(result.ocs.data.emails);
+						} else {
+							var emails = [];
+						}
 
 						var usersLength;
 						var groupsLength;