diff --git a/module/VuFind/src/VuFind/Controller/AbstractRecord.php b/module/VuFind/src/VuFind/Controller/AbstractRecord.php
index d91a8eb3f7a0b44810e33d79883b2decb772dacc..745709238dd116f44df39717b58bf84b2498b75b 100644
--- a/module/VuFind/src/VuFind/Controller/AbstractRecord.php
+++ b/module/VuFind/src/VuFind/Controller/AbstractRecord.php
@@ -365,14 +365,15 @@ class AbstractRecord extends AbstractBase
         if ($this->formWasSubmitted('submit', $view->useRecaptcha)) {
             // Attempt to send the email and show an appropriate flash message:
             try {
-                $this->getServiceLocator()->get('VuFind\Mailer')->sendRecord(
+                $mailer = $this->getServiceLocator()->get('VuFind\Mailer');
+                $mailer->sendRecord(
                     $view->to, $view->from, $view->message, $driver,
                     $this->getViewRenderer()
                 );
                 if ($this->params()->fromPost('ccself')
                     && $view->from != $view->to
                 ) {
-                    $this->getServiceLocator()->get('VuFind\Mailer')->sendRecord(
+                    $mailer->sendRecord(
                         $view->from, $view->from, $view->message, $driver,
                         $this->getViewRenderer()
                     );
diff --git a/module/VuFind/src/VuFind/Controller/AjaxController.php b/module/VuFind/src/VuFind/Controller/AjaxController.php
index e69635185e90c824583018f09cc35dcddaaa3afb..c72f6133c9844787de5cafb58d31384ea64f3394 100644
--- a/module/VuFind/src/VuFind/Controller/AjaxController.php
+++ b/module/VuFind/src/VuFind/Controller/AjaxController.php
@@ -1032,14 +1032,15 @@ class AjaxController extends AbstractBase
                 $this->params()->fromPost('source', 'VuFind')
             );
             $view = $this->createEmailViewModel();
-            $this->getServiceLocator()->get('VuFind\Mailer')->sendRecord(
+            $mailer = $this->getServiceLocator()->get('VuFind\Mailer');
+            $mailer->sendRecord(
                 $view->to, $view->from, $view->message, $record,
                 $this->getViewRenderer()
             );
             if ($this->params()->fromPost('ccself')
                 && $view->from != $view->to
             ) {
-                $this->getServiceLocator()->get('VuFind\Mailer')->sendRecord(
+                $mailer->sendRecord(
                     $view->from, $view->from, $view->message, $record,
                     $this->getViewRenderer()
                 );
diff --git a/module/VuFind/src/VuFind/Controller/CartController.php b/module/VuFind/src/VuFind/Controller/CartController.php
index c60cf83a115045d3693178bfd0ae1dc87712e9f7..4072ffbcd263f6830a83226810fd43c83bb7d3d7 100644
--- a/module/VuFind/src/VuFind/Controller/CartController.php
+++ b/module/VuFind/src/VuFind/Controller/CartController.php
@@ -216,14 +216,15 @@ class CartController extends AbstractBase
             // Attempt to send the email and show an appropriate flash message:
             try {
                 // If we got this far, we're ready to send the email:
-                $this->getServiceLocator()->get('VuFind\Mailer')->sendLink(
+                $mailer = $this->getServiceLocator()->get('VuFind\Mailer');
+                $mailer->sendLink(
                     $view->to, $view->from, $view->message,
                     $url, $this->getViewRenderer(), 'bulk_email_title'
                 );
                 if ($this->params()->fromPost('ccself')
                     && $view->from != $view->to
                 ) {
-                    $this->getServiceLocator()->get('VuFind\Mailer')->sendLink(
+                    $mailer->sendLink(
                         $view->from, $view->from, $view->message,
                         $url, $this->getViewRenderer(), 'bulk_email_title'
                     );
diff --git a/module/VuFind/src/VuFind/Controller/SearchController.php b/module/VuFind/src/VuFind/Controller/SearchController.php
index b229f15d765729d8fc00435fc7800686285d7a0b..6a68ba63c163e63564266758260f2e546645eb01 100644
--- a/module/VuFind/src/VuFind/Controller/SearchController.php
+++ b/module/VuFind/src/VuFind/Controller/SearchController.php
@@ -113,16 +113,17 @@ class SearchController extends AbstractSearch
             // Attempt to send the email and show an appropriate flash message:
             try {
                 // If we got this far, we're ready to send the email:
-                $this->getServiceLocator()->get('VuFind\Mailer')->sendLink(
+                $mailer = $this->getServiceLocator()->get('VuFind\Mailer');
+                $mailer->sendLink(
                     $view->to, $view->from, $view->message,
                     $view->url, $this->getViewRenderer()
                 );
                 if ($this->params()->fromPost('ccself')
                     && $view->from != $view->to
                 ) {
-                    $this->getServiceLocator()->get('VuFind\Mailer')->sendLink(
-                    $view->from, $view->from, $view->message,
-                    $view->url, $this->getViewRenderer()
+                    $mailer->sendLink(
+                        $view->from, $view->from, $view->message,
+                        $view->url, $this->getViewRenderer()
                     );
                 }
                 $this->flashMessenger()->setNamespace('info')