/** * FUNCTION: _sendMail * * Proccesses all headers and attachments ready for sending. * * @access private */ function _sendMail() { $message = new Swift_Message($this->subject); if (empty($this->sendto) and (empty($this->body) and empty($this->htmlbody))) { vlibMimeMailError::raiseError('VM_ERROR_CANNOT_SEND', FATAL); } // Attachments for ($index = 0; $index < sizeof($this->attachments); $index++) { $message->attach(new Swift_Message_Attachment(new Swift_File($this->attachments[$index]), $this->attachments[$index], $this->mimetypes[$index])); } // ReplyTo if exists if (!empty($this->replyToEmail)) { $message->setReplyTo(new Swift_Address($this->replyToEmail, $this->replyToName)); } // attach body if exist if (!empty($this->body)) { if (empty($this->htmlbody) and sizeof($this->attachments) == 0) { $message->setData($this->body); Swift_ClassLoader::load('Swift_Message_Encoder'); if (Swift_Message_Encoder::instance()->isUTF8($this->body)) { $message->setCharset('utf-8'); } else { $message->setCharset('iso-8859-1'); } } else { $message->attach(new Swift_Message_Part($this->body, 'text/plain')); } } // attach HTML body if exist if (!empty($this->htmlbody)) { $message->attach(new Swift_Message_Part($this->htmlbody, 'text/html')); } return $this->swift->send($message, $this->swift_recipients, new Swift_Address($this->fromEmail, $this->fromName)); }
/** * Send error log to administrator * * @param array $errors * @return boolean */ function backup_module_log_error($errors, $send_email = false) { $log_message = is_foreachable($errors) ? implode("\n", $errors) : $errors; if ($send_email) { $mailer =& ApplicationMailer::mailer(); $recipient = new Swift_Address(); $recipient->setAddress(ADMIN_EMAIL); $recipient->setName('activeCollab admin'); $sender = new Swift_Address(); $sender->setAddress(ConfigOptions::getValue('notifications_from_email')); $sender->setName(ConfigOptions::getValue('notifications_from_name')); $tmp_message = "Automatic backup of activeCollab on " . ROOT_URL . " failed.\n\r"; $tmp_message .= "Backup returned these errors: \n\r\n\r"; $tmp_message .= $log_message; $message = new Swift_Message(); $message->setSubject('activeCollab automatic backup error log'); $message->setData($tmp_message); $message->setContentType('text/plain'); $mailer->send($message, $recipient, $sender); } // if log_message($log_message, LOG_LEVEL_ERROR, 'backup'); }