REF Update CiviCRM default PEAR Error handling to be exception rather than just PEAR_...
[civicrm-core.git] / CRM / Utils / Mail / FilteredPearMailer.php
index 5ede19aa46ac3d8e6ad17e3499a22d2e15fd40b2..bf80e19a1f931b38452e481251180e7d48da7714 100644 (file)
@@ -56,6 +56,15 @@ class CRM_Utils_Mail_FilteredPearMailer extends Mail {
     $this->_delegate = $mailer;
   }
 
+  public function __destruct() {
+    try {
+      unset($this->_delegate);
+    }
+    catch (Exception $e) {
+      Civi::log()->error($e->getMessage());
+    }
+  }
+
   public function send($recipients, $headers, $body) {
     $filterArgs = [$this, &$recipients, &$headers, &$body];
     foreach ($this->_filters as $filter) {