コード例 #1
0
 public static function sendMail($path)
 {
     if (!\OCP\User::isLoggedIn()) {
         return;
     }
     $email = \OCP\Config::getUserValue(\OCP\User::getUser(), 'settings', 'email', '');
     \OCP\Util::writeLog('files_antivirus', 'Email: ' . $email, \OCP\Util::DEBUG);
     if (!empty($email)) {
         $defaults = new \OCP\Defaults();
         $tmpl = new \OCP\Template('files_antivirus', 'notification');
         $tmpl->assign('file', $path);
         $tmpl->assign('host', \OCP\Util::getServerHost());
         $tmpl->assign('user', \OCP\User::getDisplayName());
         $msg = $tmpl->fetchPage();
         $from = \OCP\Util::getDefaultEmailAddress('security-noreply');
         \OCP\Util::sendMail($email, \OCP\User::getUser(), \OCP\Util::getL10N('files_antivirus')->t('Malware detected'), $msg, $from, $defaults->getName(), true);
     }
 }
コード例 #2
0
 /**
  * Get the sender data
  * @param string $setting Either `email` or `name`
  * @return string
  */
 protected function getSenderData($setting)
 {
     if (empty($this->senderAddress)) {
         $this->senderAddress = \OCP\Util::getDefaultEmailAddress('no-reply');
     }
     if (empty($this->senderName)) {
         $defaults = new \OCP\Defaults();
         $this->senderName = $defaults->getName();
     }
     if ($setting === 'email') {
         return $this->senderAddress;
     }
     return $this->senderName;
 }