From ca00db7decce7d11008f0af1dc7ad58f55a130a7 Mon Sep 17 00:00:00 2001
From: Peter Rotich <peter@enhancesoft.com>
Date: Mon, 22 Apr 2019 22:53:37 +0000
Subject: [PATCH] Mailer: Allow for ability to pass -f option as from_address

---
 include/class.mailer.php | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/include/class.mailer.php b/include/class.mailer.php
index 620cd84de..15a08d1df 100644
--- a/include/class.mailer.php
+++ b/include/class.mailer.php
@@ -587,7 +587,9 @@ class Mailer {
 
         //No SMTP or it failed....use php's native mail function.
         $args = array();
-        if ($this->getEmail())
+        if (isset($options['from_address']))
+            $args[] = '-f '.$options['from_address'];
+        elseif ($this->getEmail())
             $args = array('-f '.$this->getEmail()->getEmail());
         $mail = mail::factory('mail', $args);
         $to = $headers['To'];
@@ -612,10 +614,10 @@ class Mailer {
 
     //Emails using native php mail function - if DB connection doesn't exist.
     //Don't use this function if you can help it.
-    function sendmail($to, $subject, $message, $from) {
+    function sendmail($to, $subject, $message, $from, $options=null) {
         $mailer = new Mailer(null, array('notice'=>true, 'nobounce'=>true));
         $mailer->setFromAddress($from);
-        return $mailer->send($to, $subject, $message);
+        return $mailer->send($to, $subject, $message, $options);
     }
 }
 ?>
-- 
GitLab