From 34dcd13a1279f3bd2d96cd9303d73a1c2717a4c9 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Fri, 5 Dec 2008 10:56:30 -0700 Subject: [PATCH] Clean up SPAM reporting. No need for separate bounce address - bouncing will necessarily alter the headers so it is worthless for message analysis - it is only useful for token/signature scanning. However, this kind of scanning works just fine if we attach the original message as a message/rfc822 part (e.g. DSPAM). --- imp/config/conf.xml | 28 ++++----- imp/config/hooks.php.dist | 10 ++-- imp/docs/UPGRADING | 1 + imp/imp-dimp.php | 4 +- imp/lib/Spam.php | 150 +++++++++++++--------------------------------- imp/mailbox.php | 3 +- imp/message.php | 3 +- 7 files changed, 61 insertions(+), 138 deletions(-) diff --git a/imp/config/conf.xml b/imp/config/conf.xml index cec9f2c49..82c387329 100644 --- a/imp/config/conf.xml +++ b/imp/config/conf.xml @@ -231,15 +231,13 @@ false - - + tokens/signatures process contained in the original mail, etc.). If you + need to dynamically set the email address for each user (e.g. DSPAM), + this setting should be empty and you should look at the + _imp_hook_spam_email hook instead."/> - + tokens/signatures process contained in the original mail, etc.). If you + need to dynamically set the email address for each user (e.g. DSPAM), + this setting should be empty and you should look at the + _imp_hook_spam_email hook instead."/> false - false getBody(); + /* Send the message. */ + $imp_compose->sendMessage($to, $spam_headers, $mime, NLS::getCharset()); + $report_flag = true; + } - $this->_impCompose->sendMessage($to, $imp_headers, $bodytext, NLS::getCharset()); - if (!$report_flag) { - $report_msg_count++; - } + if ($report_flag) { + ++$report_count; } } } /* Report what we've done. */ - if ($report_msg_count) { + if ($report_count) { switch ($action) { case 'spam': - if ($report_msg_count > 1) { - $notification->push(sprintf(_("%d messages have been reported as spam."), $report_msg_count), 'horde.message'); + if ($report_count > 1) { + $notification->push(sprintf(_("%d messages have been reported as spam."), $report_count), 'horde.message'); } else { $notification->push(_("The message has been reported as spam."), 'horde.message'); } break; case 'notspam': - if ($report_msg_count > 1) { - $notification->push(sprintf(_("%d messages have been reported as not spam."), $report_msg_count), 'horde.message'); + if ($report_count > 1) { + $notification->push(sprintf(_("%d messages have been reported as not spam."), $report_count), 'horde.message'); } else { $notification->push(_("The message has been reported as not spam."), 'horde.message'); } @@ -174,26 +154,6 @@ class IMP_Spam } } - if ($email_msg_count) { - switch ($action) { - case 'spam': - if ($email_msg_count > 1) { - $notification->push(sprintf(_("%d messages have been reported as spam to your system administrator."), $email_msg_count), 'horde.message'); - } else { - $notification->push(_("The message has been reported as spam to your system administrator."), 'horde.message'); - } - break; - - case 'notspam': - if ($email_msg_count > 1) { - $notification->push(sprintf(_("%d messages have been reported as not spam to your system administrator."), $email_msg_count), 'horde.message'); - } else { - $notification->push(_("The message has been reported as not spam to your system administrator."), 'horde.message'); - } - break; - } - } - /* Delete spam after report. */ $delete_spam = $GLOBALS['prefs']->getValue('delete_spam_after_report'); if ($delete_spam) { @@ -230,34 +190,4 @@ class IMP_Spam return $delete_spam; } - - /** - * Send a (not)spam message to the sysadmin. - * - * @param string $action The action type. - * @param string $data The message data. - */ - protected function _sendSpamReportMessage($action, $data) - { - /* Build the MIME structure. */ - $mime = new Horde_Mime_Part(); - $mime->setType('multipart/digest'); - - $rfc822 = new Horde_Mime_Part(); - $rfc822->setType('message/rfc822'); - $rfc822->setContents($data); - $mime->addPart($rfc822); - - $spam_headers = new Horde_Mime_Headers(); - $spam_headers->addMessageIdHeader(); - $spam_headers->addHeader('Date', date('r')); - $spam_headers->addHeader('To', $GLOBALS['conf'][$action]['email']); - $spam_headers->addHeader('From', $this->_identity->getFromLine()); - $spam_headers->addHeader('Subject', - sprintf(_("%s report from %s"), - $action, $_SESSION['imp']['user'])); - - /* Send the message. */ - $this->_impCompose->sendMessage($GLOBALS['conf'][$action]['email'], $spam_headers, $mime, NLS::getCharset()); - } } diff --git a/imp/mailbox.php b/imp/mailbox.php index 7a295551b..0a79f927a 100644 --- a/imp/mailbox.php +++ b/imp/mailbox.php @@ -114,8 +114,7 @@ case 'whitelist': case 'spam_report': case 'notspam_report': $action = str_replace('_report', '', $actionID); - $imp_spam = new IMP_Spam(); - $imp_spam->reportSpam($indices, $action); + IMP_Spam::reportSpam($indices, $action); break; case 'message_missing': diff --git a/imp/message.php b/imp/message.php index db0bd2cb9..21d5c140d 100644 --- a/imp/message.php +++ b/imp/message.php @@ -136,8 +136,7 @@ case 'copy_message': case 'spam_report': case 'notspam_report': $action = str_replace('_report', '', $actionID); - $imp_spam = new IMP_Spam(); - switch ($imp_spam->reportSpam($indices_array, $action)) { + switch (IMP_Spam::reportSpam($indices_array, $action)) { case 1: if (_moveAfterAction()) { $imp_mailbox->setIndex(1, 'offset'); -- 2.11.0