SOURCES: eventum-bounce-notes.patch (NEW) - when using mail_downlo...

glen glen at pld-linux.org
Tue Apr 3 00:45:57 CEST 2007


Author: glen                         Date: Mon Apr  2 22:45:57 2007 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- when using mail_download eventum should generate itself error bounces

---- Files affected:
SOURCES:
   eventum-bounce-notes.patch (NONE -> 1.1)  (NEW)

---- Diffs:

================================================================
Index: SOURCES/eventum-bounce-notes.patch
diff -u /dev/null SOURCES/eventum-bounce-notes.patch:1.1
--- /dev/null	Tue Apr  3 00:45:57 2007
+++ SOURCES/eventum-bounce-notes.patch	Tue Apr  3 00:45:52 2007
@@ -0,0 +1,113 @@
+Index: include/class.support.php
+===================================================================
+--- include/class.support.php	(revision 3290)
++++ include/class.support.php	(working copy)
+@@ -456,6 +461,50 @@
+ 
+ 
+     /**
++     * Bounce message to sender.
++     *
++     * @access  public
++     * @param   object  $message parsed message structure.
++     * @param   array   array(ERROR_CODE, ERROR_STRING) of error to bounce
++     * @return  void
++     */
++    function BounceEmail($message, $error)
++    {
++        // open text template
++        $tpl = new Template_API;
++        $tpl->setTemplate('notifications/bounced_email.tpl.text');
++        $tpl->bulkAssign(array(
++            'error_code'        => $error[0],
++            'error_message'     => $error[1],
++            'date'              => $message->date,
++            'subject'           => Mime_Helper::fixEncoding($message->subject),
++            'from'              => Mime_Helper::fixEncoding($message->fromaddress),
++            'to'                => Mime_Helper::fixEncoding($message->toaddress),
++            'cc'                => Mime_Helper::fixEncoding(@$message->ccaddress),
++        ));
++
++        $sender_email = Mail_API::getEmailAddress($message->fromaddress);
++        $usr_id = User::getUserIDByEmail($sender_email);
++        // change the current locale
++        if ($usr_id) {
++            Language::set(User::getLang($usr_id));
++        }
++
++        $text_message = $tpl->getTemplateContents();
++
++        // send email (use PEAR's classes)
++        $mail = new Mail_API;
++        $mail->setTextBody($text_message);
++        $setup = $mail->getSMTPSettings();
++        $mail->send($setup['from'], $sender_email,
++            APP_SHORT_NAME . ': ' . ev_gettext('Postmaster notify: see transcript for details'));
++
++        if ($usr_id) {
++            Language::restore();
++        }
++    }
++
++    /**
+      * Method used to get the information about a specific message
+      * from a given mailbox.
+      *
+@@ -531,10 +580,11 @@
+                     $res = Routing::getMatchingIssueIDs($addresses, 'email');
+                     if ($res != false) {
+                         $return = Routing::route_emails($message);
+-                        if ($return == true) {
++                        if ($return === true) {
+                             Support::deleteMessage($info, $mbox, $num);
+                             return;
+                         }
++                        // TODO: handle errors?
+                         return;
+                     }
+                 }
+@@ -542,10 +592,13 @@
+                     $res = Routing::getMatchingIssueIDs($addresses, 'note');
+                     if ($res != false) {
+                         $return = Routing::route_notes($message);
+-                        if ($return == true) {
++                        if ($return === true) {
+                             Support::deleteMessage($info, $mbox, $num);
+                             return;
+                         }
++
++                        // create bounce
++                        Support::BounceEmail($email, $return);
+                         return;
+                     }
+                 }
+@@ -553,10 +606,11 @@
+                     $res = Routing::getMatchingIssueIDs($addresses, 'draft');
+                     if ($res != false) {
+                         $return = Routing::route_drafts($message);
+-                        if ($return == true) {
++                        if ($return === true) {
+                             Support::deleteMessage($info, $mbox, $num);
+                             return;
+                         }
++                        // TODO: handle errors?
+                         return;
+                     }
+                 }
+Index: templates/notifications/bounced_email.tpl.text
+===================================================================
+--- templates/notifications/bounced_email.tpl.text	(revision 0)
++++ templates/notifications/bounced_email.tpl.text	(revision 0)
+@@ -0,0 +1,12 @@
++----- {t escape=no}Eventum was unable to route your email{/t} -----
++{$error_message}
++
++----- {t escape=no}The original message headers follow{/t} -----
++{$original_message}
++Date: {$date}
++Subject: {$subject}
++From: {$from}
++To: {$to}
++{if $cc!=''}
++Cc: {$cc}
++{/if}
================================================================


More information about the pld-cvs-commit mailing list