From: hickert Date: Mon, 19 Jan 2009 10:10:09 +0000 (+0000) Subject: Added uw-imap plugin X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=a37055d5ef7dbd2415cd428cba41aa7a226cb519;p=gosa.git Added uw-imap plugin git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@13364 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-plugins/uwimap/contrib/procmail-discard.txt b/gosa-plugins/uwimap/contrib/procmail-discard.txt new file mode 100644 index 000000000..365707bdc --- /dev/null +++ b/gosa-plugins/uwimap/contrib/procmail-discard.txt @@ -0,0 +1,4 @@ +# Discard any local messages +:0 : +/dev/null + diff --git a/gosa-plugins/uwimap/contrib/procmail-footer.txt b/gosa-plugins/uwimap/contrib/procmail-footer.txt new file mode 100644 index 000000000..ae0b579b1 --- /dev/null +++ b/gosa-plugins/uwimap/contrib/procmail-footer.txt @@ -0,0 +1,10 @@ +# Care for cleanups + +# Remove stale vacation cache +:0 +* ! \$GOSA_VACATION ?? yes +* ! ? test -f \$VACATION_CACHE +{ + rm -f \$VACATION_CACHE +} + diff --git a/gosa-plugins/uwimap/contrib/procmail-header.txt b/gosa-plugins/uwimap/contrib/procmail-header.txt new file mode 100644 index 000000000..d56dc8fbc --- /dev/null +++ b/gosa-plugins/uwimap/contrib/procmail-header.txt @@ -0,0 +1,15 @@ +#*** Procmail script for $user *** + +DROPPRIVS=true + + +# Include variable definitions from procmail library +INCLUDERC=\$PMSRC/pm-javar.rc + + +# Check for empty body and discard +:0 B: +*\$ ! \$NSPC +/dev/null + + diff --git a/gosa-plugins/uwimap/contrib/procmail-spam.txt b/gosa-plugins/uwimap/contrib/procmail-spam.txt new file mode 100644 index 000000000..7616dd1cb --- /dev/null +++ b/gosa-plugins/uwimap/contrib/procmail-spam.txt @@ -0,0 +1,34 @@ +# procmail spam handling +GOSA_SPAM="yes" + +:0 +* ! ^From:.*($addrlist) +* ! FROM_DAEMON +{ + + # Do not add extra headers. This saves external shell call + # (formail). Also do not try to kill the message content, + # again saving one external call (awk). With these, the + # recipe is faster and more CPU friendly. + PM_JA_UBE_HDR = "" + JA_UBE_ATTACHMENT_ILLEGAL_KILL = "no" + JA_UBE_FLAG_FROM_NSLOOKUP = "no" + + INCLUDERC = \$PMSRC/pm-jaube.rc + + # Variable "ERROR" is set if message was UBE, record error + # to log file with "()\/" + + :0 : + * ERROR ?? ()\/[a-z].* + { + # Don't save those *.exe, *.zip UBE attachements + :0 + * ERROR ?? Attachment-FileIllegal + /dev/null + + :0 : + $spambox + } +} + diff --git a/gosa-plugins/uwimap/contrib/procmail-vacation.txt b/gosa-plugins/uwimap/contrib/procmail-vacation.txt new file mode 100644 index 000000000..d3b0c751a --- /dev/null +++ b/gosa-plugins/uwimap/contrib/procmail-vacation.txt @@ -0,0 +1,35 @@ +# Vacation message +GOSA_VACATION=yes +VACATION_CACHE=\$HOME/.vacation.cache + +:0 +* ^TO_$mail +* ! ^FROM_DAEMON +* ! ^X-Loop: ($addrlist) +* ! ^Precedence:.*(bulk|list|junk) +{ + :0 c: \$HOME/.vacation.\$LOCKEXT + * ! ? formail -rD 8192 \$VACATION_CACHE + { + # Compose reply and add some basic headers + :0 fhw + | formail -rt \ + -A "Precedence: junk" \ + -A "X-Loop: $mail" + + :0 a # Formail succeeded + { + # Change subject + :0 fhw + * ^Subject: *\/[^ ].* + | formail -I "Subject: vacation (was: \$MATCH)" + + :0 fb # put message to body + | echo -n "$vacmsg" + + :0 # Send it + | \$SENDMAIL + } + } +} + diff --git a/gosa-plugins/uwimap/personal/mail/class_mail-methods-uwimap.inc b/gosa-plugins/uwimap/personal/mail/class_mail-methods-uwimap.inc new file mode 100644 index 000000000..4aa558c56 --- /dev/null +++ b/gosa-plugins/uwimap/personal/mail/class_mail-methods-uwimap.inc @@ -0,0 +1,146 @@ +config->data['SERVERS']['IMAP'])){ + $this->ServerList = $this->config->data['SERVERS']['IMAP']; + } + + /* Check for required PROCMAIL_PATH configuration + */ + if($this->config->get_cfg_value("procMailPath","") == ""){ + msg_dialog::display(_("Configuration error"),msgPool::invalidConfigurationAttribute("procMailPath"), ERROR_DIALOG); + $this->procmaildir = ""; + }else{ + $this->procmaildir = $this->config->data['MAIN']['PROCMAIL_PATH']; + } + } + + + public function saveSieveSettings() + { + if(empty($this->procmaildir)){ + @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__, "", + "MAIL: Skippend writting scripts, 'procMailPath' is not configured"); + return; + } + + mailMethod::saveSieveSettings(); + /* Map attribute from parent class + */ + $mail = $this->parent->mail; + $gosaMailDeliveryMode = $this->parent->gosaMailDeliveryMode; + $gosaMailAlternateAddress = $this->parent->gosaMailAlternateAddress; + $gosaMailMaxSize = $this->parent->gosaMailMaxSize; + $gosaSpamMailbox = $this->parent->gosaSpamMailbox; + $gosaSpamSortLevel = $this->parent->gosaSpamSortLevel; + $gosaVacationMessage = $this->parent->gosaVacationMessage; + + $recipe = ""; + $addrlist = $mail; + foreach ($gosaMailAlternateAddress as $val){ + $addrlist .= "|$val"; + } + $user = $this->getUAttribValue(); + + /* Only create a new one, if it is not empty */ + if (is_integer(strpos($gosaMailDeliveryMode, "R")) || + is_integer(strpos($gosaMailDeliveryMode, "C")) || + !is_integer(strpos($gosaMailDeliveryMode, "L")) || + is_integer(strpos($gosaMailDeliveryMode, "V")) || + is_integer(strpos($gosaMailDeliveryMode, "S"))) { + $text= implode ("", file(CONFIG_DIR."/procmail-header.txt")); + $text = preg_replace('/"/', '\\"', $text); + eval ("\$recipe.=\"$text\";"); + } + + /* Add anti-spam variables */ + if (is_integer(strpos($gosaMailDeliveryMode, "S"))) { + $spambox = $gosaSpamMailbox; + $spamlevel = $gosaSpamSortLevel; + $text= implode ("", file(CONFIG_DIR."/procmail-spam.txt")); + $text = preg_replace('/"/', '\\"', $text); + eval ("\$recipe.=\"$text\";"); + } + + /* Add vacation recipe */ + if (is_integer(strpos($gosaMailDeliveryMode, "V"))) { + $vacmsg = $gosaVacationMessage; + $text= implode ("", file(CONFIG_DIR."/procmail-vacation.txt")); + $text = preg_replace('/"/', '\\"', $text); + eval ("\$recipe.=\"$text\";"); + } + + /* Check if no local delivery is wanted */ + if (!is_integer(strpos($gosaMailDeliveryMode, "L"))) { + $text= implode ("", file(CONFIG_DIR."/procmail-discard.txt")); + $text = preg_replace('/"/', '\\"', $text); + eval ("\$recipe.=\"$text\";"); + } + + /* Write procmail script */ + if (!empty($recipe)) { + $text= implode ("", file(CONFIG_DIR."/procmail-footer.txt")); + $text = preg_replace('/"/', '\\"', $text); + eval ("\$recipe.=\"$text\";"); + $file = $this->procmaildir . "/" . $this->getUAttribValue(); + + if (!file_put_contents($file, $recipe)) { + msg_dialog::display(_("Error"),(sprintf(_("Unable to write procmail script to '%s'."), $file)),ERROR_DIALOG); + } + } + } + +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-plugins/uwimap/plugin.dsc b/gosa-plugins/uwimap/plugin.dsc new file mode 100644 index 000000000..d3083a2f7 --- /dev/null +++ b/gosa-plugins/uwimap/plugin.dsc @@ -0,0 +1,7 @@ +[gosa-plugin] +name = uw-imap +description = "UW imap mail method" +version = 2.6.3 +author = "Gero Kuhlmann , Fabian Hickert " +homepage = https://oss.gonicus.de/labs/gosa/ +depends = mail