diff --git a/config/vufind/config.ini b/config/vufind/config.ini
index 9cbda6c4936a5ea361ba067a6b1ae885d98cf5c1..5a6cce97cf5be2255447447765826765c870c3fc 100644
--- a/config/vufind/config.ini
+++ b/config/vufind/config.ini
@@ -240,6 +240,8 @@ host            = localhost
 port            = 25
 ;username       = user
 ;password       = pass
+; If set to false, users can send anonymous emails; otherwise, they must log in first
+require_login   = true
 
 ; This section needs to be changed to match your database connection information
 [Database]
diff --git a/module/VuFind/src/VuFind/Controller/AbstractRecord.php b/module/VuFind/src/VuFind/Controller/AbstractRecord.php
index 260c21a81ca2de71a261c4e08fc8c91972b09e44..3f7e7ccd2b944ccdb974e2fbda21d454cbf7b04c 100644
--- a/module/VuFind/src/VuFind/Controller/AbstractRecord.php
+++ b/module/VuFind/src/VuFind/Controller/AbstractRecord.php
@@ -341,6 +341,14 @@ class AbstractRecord extends AbstractBase
      */
     public function emailAction()
     {
+        // Force login if necessary:
+        $config = \VuFind\Config\Reader::getConfig();
+        if ((!isset($config->Mail->require_login) || $config->Mail->require_login)
+            && !$this->getUser()
+        ) {
+            return $this->forceLogin();
+        }
+
         // Retrieve the record driver:
         $driver = $this->loadRecord();
 
diff --git a/module/VuFind/src/VuFind/Controller/AjaxController.php b/module/VuFind/src/VuFind/Controller/AjaxController.php
index 32dff95f474289878a711b0245dfe4599ae9395a..e2baa303d05671fcce9216be047c02e11e0d9418 100644
--- a/module/VuFind/src/VuFind/Controller/AjaxController.php
+++ b/module/VuFind/src/VuFind/Controller/AjaxController.php
@@ -972,6 +972,18 @@ class AjaxController extends AbstractBase
     public function emailRecord()
     {
         $this->writeSession();  // avoid session write timing bug
+
+        // Force login if necessary:
+        $config = \VuFind\Config\Reader::getConfig();
+        if ((!isset($config->Mail->require_login) || $config->Mail->require_login)
+            && !$this->getUser()
+        ) {
+            return $this->output(
+                $this->translate('You must be logged in first'),
+                self::STATUS_NEED_AUTH
+            );
+        }
+
         // Attempt to send the email:
         try {
             $record = $this->getRecordLoader()->load(
@@ -1001,6 +1013,18 @@ class AjaxController extends AbstractBase
     public function emailSearch()
     {
         $this->writeSession();  // avoid session write timing bug
+
+        // Force login if necessary:
+        $config = \VuFind\Config\Reader::getConfig();
+        if ((!isset($config->Mail->require_login) || $config->Mail->require_login)
+            && !$this->getUser()
+        ) {
+            return $this->output(
+                $this->translate('You must be logged in first'),
+                self::STATUS_NEED_AUTH
+            );
+        }
+
         // Make sure URL is properly formatted -- if no protocol is specified, run it
         // through the serverurl helper:
         $url = $this->params()->fromPost('url');
diff --git a/module/VuFind/src/VuFind/Controller/CartController.php b/module/VuFind/src/VuFind/Controller/CartController.php
index c7bdffa0cd9e269f0be0e895727f5651f3d97e8d..95f080442e14d98b865f194f0a1c61b8b6034f68 100644
--- a/module/VuFind/src/VuFind/Controller/CartController.php
+++ b/module/VuFind/src/VuFind/Controller/CartController.php
@@ -166,6 +166,14 @@ class CartController extends AbstractBase
      */
     public function emailAction()
     {
+        // Force login if necessary:
+        $config = \VuFind\Config\Reader::getConfig();
+        if ((!isset($config->Mail->require_login) || $config->Mail->require_login)
+            && !$this->getUser()
+        ) {
+            return $this->forceLogin();
+        }
+
         $ids = is_null($this->params()->fromPost('selectAll'))
             ? $this->params()->fromPost('ids')
             : $this->params()->fromPost('idsAll');
diff --git a/module/VuFind/src/VuFind/Controller/SearchController.php b/module/VuFind/src/VuFind/Controller/SearchController.php
index 7f5488a8d6459db90e8e71e5451bdb43ab2d5976..01863d9494acd793d074f6caf4d2a5ba40b43db5 100644
--- a/module/VuFind/src/VuFind/Controller/SearchController.php
+++ b/module/VuFind/src/VuFind/Controller/SearchController.php
@@ -84,6 +84,21 @@ class SearchController extends AbstractSearch
             )
         );
 
+        // Force login if necessary:
+        $config = \VuFind\Config\Reader::getConfig();
+        if ((!isset($config->Mail->require_login) || $config->Mail->require_login)
+            && !$this->getUser()
+        ) {
+            return $this->forceLogin(null, array('emailurl' => $view->url));
+        }
+
+        // Check if we have a URL in login followup data:
+        $followup = $this->followup()->retrieve();
+        if (isset($followup->emailurl)) {
+            $view->url = $followup->emailurl;
+            unset($followup->emailurl);
+        }
+
         // Fail if we can't figure out a URL to share:
         if (empty($view->url)) {
             throw new \Exception('Cannot determine URL to share.');
diff --git a/themes/blueprint/js/common.js b/themes/blueprint/js/common.js
index 0379f3a077d5a0898c471f9ef63abba81467911d..68cdb97e2d0c231c3e3fdb3b3ddc0b23bf907ae4 100644
--- a/themes/blueprint/js/common.js
+++ b/themes/blueprint/js/common.js
@@ -45,7 +45,7 @@ $(document).ready(function(){
     // assign click event to "email search" links
     $('a.mailSearch').click(function() {
         var id = this.id.substr('mailSearch'.length);
-        var $dialog = getLightbox('Search', 'Email', id, null, this.title);
+        var $dialog = getLightbox('Search', 'Email', id, null, this.title, 'Search', 'Email', id);
         return false;
     });
 
diff --git a/themes/blueprint/js/record.js b/themes/blueprint/js/record.js
index e1f74085e15f79b228aea9e42d31218be44c49fc..8bde4929a445f0ae578cd6cd14acd93caad2b2e4 100644
--- a/themes/blueprint/js/record.js
+++ b/themes/blueprint/js/record.js
@@ -26,7 +26,7 @@ $(document).ready(function(){
     });
     $('a.mailRecord').click(function() {
         var controller = extractController(this);
-        var $dialog = getLightbox(controller, 'Email', id, null, this.title);
+        var $dialog = getLightbox(controller, 'Email', id, null, this.title, controller, 'Email', id);
         return false;
     });
     $('a.tagRecord').click(function() {