[dev] [PATCH] Ingo + procmail + vacation message
Micha Kersloot
micha at kovoks.nl
Fri May 7 14:08:09 PDT 2004
Hi,
I wrote the next patch for ingo to use procmail for sending vacation messages.
The basics come from the examples in the procmailex man pages.
--
Met vriendelijke groet,
Micha Kersloot
http://www.kovoks.nl
Index: procmail.php
===================================================================
RCS file: /repository/ingo/lib/Script/procmail.php,v
retrieving revision 1.43
diff -u -r1.43 procmail.php
--- procmail.php 9 Mar 2004 18:05:03 -0000 1.43
+++ procmail.php 7 May 2004 21:00:23 -0000
@@ -40,6 +40,7 @@
var $_categories = array(
INGO_STORAGE_ACTION_BLACKLIST,
INGO_STORAGE_ACTION_WHITELIST,
+ INGO_STORAGE_ACTION_VACATION,
INGO_STORAGE_ACTION_FORWARD
);
@@ -142,6 +143,10 @@
$this->generateWhitelist(!empty($filter['disable']));
break;
+ case INGO_STORAGE_ACTION_VACATION:
+ $this->generateVacation(!empty($filter['disable']));
+ break;
+
case INGO_STORAGE_ACTION_FORWARD:
$this->generateForward(!empty($filter['disable']));
break;
@@ -243,6 +248,37 @@
}
}
+ /**
+ * Generates the procmail script to handle vacation.
+ *
+ * @access public
+ *
+ * @param optional boolean $disable Disable vacation?
+ */
+ function generateVacation($disable = false)
+ {
+ global $ingo_storage;
+
+ $vacation = $ingo_storage->retrieve(INGO_STORAGE_ACTION_VACATION);
+ $addresses = $vacation->getVacationAddresses();
+ $actionval = array('addresses' => $addresses,
+ 'subject' => $vacation->getVacationSubject(),
+ 'days' => $vacation->getVacationDays(),
+ 'reason' => $vacation->getVacationReason(),
+ 'ignorelist' => $vacation->getVacationIgnorelist(),
+ 'excludes' => $vacation->getVacationExcludes());
+
+ if (!empty($addresses))
+ {
+ $this->addItem(new Procmail_Comment(_("Vacation"), $disable, true));
+ $params = array('action' => INGO_STORAGE_ACTION_VACATION,
+ 'action-value' => $actionval,
+ 'disable' => $disable);
+ $recipe = &new Procmail_Recipe($params, $this->_params);
+ $this->addItem($recipe);
+ }
+ }
+
/**
* Generates the procmail script to handle mail forwards.
*
@@ -408,7 +444,37 @@
$this->_action[] = ' HOST="no.address.here"';
$this->_action[] = '}';
break;
-
+
+ case INGO_STORAGE_ACTION_VACATION:
+ $this->_action[] = '{';
+ foreach ($params['action-value']['addresses'] as $addres) {
+ if (!empty($addres)) {
+ $this->_action[] = ' :0 Whc: vacation.lock';
+ $this->_action[] = ' * $^To:.*' . $addres;
+ $this->_action[] = ' * !^X-Loop: ' . $addres;
+ if (count($params['action-value']['excludes']) > 0) {
+ foreach ($params['action-value']['excludes'] as $exclude) {
+ if (!empty($exclude)) {
+ $this->_action[] = ' * !^From.*' . $exclude;
+ }
+ }
+ }
+ if ($params['action-value']['ignorelist']) {
+ $this->_action[] = ' * !^FROM_DAEMON';
+ }
+ $reason = $params['action-value']['reason'];
+ $this->_action[] = ' | formail -rD 8192 vacation.' . $addres;
+ $this->_action[] = ' :0 ehc';
+ $this->_action[] = ' | (formail -rI"Precedence: junk" \\';
+ $this->_action[] = ' -A"X-Loop: ' . $addres . '" ; \\';
+ $this->_action[] = ' echo " ' . ereg_replace("\r\n","\"; echo
\"",$reason) . '" \\';
+ $this->_action[] = ' ) | $SENDMAIL -oi -t';
+ $this->_action[] = '';
+ }
+ }
+ $this->_action[] = '}';
+ break;
+
case INGO_STORAGE_ACTION_FORWARD:
$this->_action[] = '{';
foreach ($params['action-value'] as $address) {
More information about the dev
mailing list