diff --git a/include/class.client.php b/include/class.client.php
index 2d1f2930c12b2cc8201fc8313b54656836625fac..d58f153156c2dbc5a433ede22dc33fb23765b59b 100644
--- a/include/class.client.php
+++ b/include/class.client.php
@@ -58,25 +58,21 @@ implements EmailContact, ITicketUser, TemplateVariable {
         switch (strtolower($tag)) {
         case 'ticket_link':
             $qstr = array();
+            $ticket = $this->getTicket();
             if ($cfg && $cfg->isAuthTokenEnabled()
-                    && ($ticket=$this->getTicket())) {
-                      if (!$ticket->getThread()->getNumCollaborators()) {
-                          $qstr['auth'] = $ticket->getAuthToken($this);
-                          return sprintf('%s/view.php?%s',
-                               $cfg->getBaseUrl(),
-                               Http::build_query($qstr, false)
-                               );
-                      }
-                      else {
-                          return sprintf('%s/tickets.php?id=%s',
-                               $cfg->getBaseUrl(),
-                               $ticket->getId()
-                               );
-                      }
-                    }
-
-
-
+                    && $ticket
+                    && !$ticket->getNumCollaborators()) {
+                $qstr['auth'] = $ticket->getAuthToken($this);
+                return sprintf('%s/view.php?%s',
+                        $cfg->getBaseUrl(),
+                        Http::build_query($qstr, false)
+                        );
+            } else {
+                return sprintf('%s/tickets.php?id=%s',
+                        $cfg->getBaseUrl(),
+                        $ticket ? $ticket->getId() : 0
+                        );
+            }
             break;
         }
     }
diff --git a/include/class.mailer.php b/include/class.mailer.php
index 620cd84de92150beda0af5a08ff95e5db1c4d608..15a08d1df9657e576ea0d4b4c69fb803547d56ae 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);
     }
 }
 ?>