Exemplo n.º 1
0
 function Send()
 {
     $emails = $this->getAllTo();
     // limit to max 15 email target addresses
     if (count($emails) > 15) {
         $emails = array_slice($emails, 0, 15);
     }
     if (strpos($this->body, "{login_code}") !== false) {
         FSS_Settings::set('email_send_multiple', "multi");
     }
     if (FSS_Settings::Get('email_send_multiple') == "to" || FSS_Settings::Get('email_send_multiple') == "bcc") {
         $mailer = $this->getMailer();
         $mailer->isHTML($this->ishtml);
         $mailer->setSubject($this->subject);
         $mailer->setBody($this->body);
         foreach ($emails as $email => $name) {
             if (trim($email) == "") {
                 continue;
             }
             if (FSS_Settings::Get('email_send_multiple') == "bcc") {
                 $mailer->addBCC(array($email));
             } else {
                 $mailer->addRecipient(array($email));
             }
         }
         foreach ($this->files as $filename => $display) {
             $mailer->addAttachment($display, $filename);
         }
         $this->debug_data['mailer'] = $mailer;
         //SupportActions::DoAction("beforeEMailSend", $this->debug_data['Ticket'], $this->debug_data);
         unset($this->debug_data['mailer']);
         $mailer->Send();
     } else {
         foreach ($emails as $email => $name) {
             if (trim($email) == "") {
                 continue;
             }
             $mailer = $this->getMailer();
             $mailer->isHTML($this->ishtml);
             $body = $this->body;
             // strip and replace login code if its in the email
             if (strpos($body, "{login_code}") !== false) {
                 // lookup user_id from email
                 $db = JFactory::getDBO();
                 $sql = "SELECT id FROM #__users WHERE email = '" . $db->escape($email) . "'";
                 $db->setQuery($sql);
                 $user_id = $db->loadResult();
                 if ($user_id > 1) {
                     $body = str_replace("{login_code}", FSS_Helper::AutoLoginCreate($user_id), $body);
                 } else {
                     $body = str_replace("{login_code}", "", $body);
                 }
             }
             $mailer->setSubject($this->subject);
             $mailer->setBody($body);
             $mailer->addRecipient(array($email));
             foreach ($this->files as $filename => $display) {
                 $mailer->addAttachment($filename, $display);
             }
             $this->debug_data['mailer'] = $mailer;
             //SupportActions::DoAction("beforeEMailSend", $this->debug_data['Ticket'], $this->debug_data);
             unset($this->debug_data['mailer']);
             $mailer->Send();
         }
     }
     $this->doLog();
 }